sapi_windows_vt100_support

(PHP 7 >= 7.2.0, PHP 8)

sapi_windows_vt100_supportGet or set VT100 support for the specified stream associated to an output buffer of a Windows console.

Beschreibung

sapi_windows_vt100_support(resource $stream, ?bool $enable = null): bool

If enable is null, the function returns true if the stream stream has VT100 control codes enabled, false otherwise.

If enable is a bool, the function will try to enable or disable the VT100 features of the stream stream. If the feature has been successfully enabled (or disabled), the function will return true, or false otherwise.

At startup, PHP tries to enable the VT100 feature of the STDOUT/STDERR streams. By the way, if those streams are redirected to a file, the VT100 features may not be enabled.

If VT100 support is enabled, it is possible to use control sequences as they are known from the VT100 terminal. They allow the modification of the terminal's output. On Windows these sequences are called Console Virtual Terminal Sequences.

Warnung

This function uses the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag implemented in the Windows 10 API, so the VT100 feature may not be available on older Windows versions.

Parameter-Liste

stream

The stream on which the function will operate.

enable

If bool, the VT100 feature will be enabled (if true) or disabled (if false).

Rückgabewerte

If enable is null: returns true if the VT100 feature is enabled, false otherwise.

If enable is a bool: Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Changelog

Version Beschreibung
8.0.0 enable is now nullable.

Beispiele

Beispiel #1 sapi_windows_vt100_support() default state

By default, STDOUT and STDERR have the VT100 feature enabled.

php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));"

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

true true

By the way, if a stream is redirected, the VT100 feature will not be enabled:

php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));" 2>NUL

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:


true false

Beispiel #2 sapi_windows_vt100_support() changing state

You won't be able to enable the VT100 feature of STDOUT or STDERR if the stream is redirected.

php -r "var_export(sapi_windows_vt100_support(STDOUT, true));echo ' ';var_export(sapi_windows_vt100_support(STDERR, true));" 2>NUL

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

true false

Beispiel #3 Example usage of VT100 support enabled

<?php
$out 
fopen('php://stdout','w');
fwrite($out'Just forgot a lettr.');
// Moves the cursor two characters backwards
fwrite($out"\033[2D");
// Inserts one blank, shifting existing text to the right -> Just forgot a lett r.
fwrite($out"\033[1@");
fwrite($out'e');
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Just forgot a letter.

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

MovieClip leeren (AS3)

Ich war wirklich besorgt um meine bachelorarbeit schreiben lassen​ (https://xn--ghostwriter-sterreich-sec.at/bachelorarbeit-schreiben-lassen/). ...

Geschrieben von Farebn am 26.04.2024 22:50:34
Forum: Grafik / Design / Flash ...
Berechnungen durchführen

Hallo liebe Forenmitglieder, meine erste frage ist zum Aufbau meiner kleinen Berechnungswebseite, nichts kommerzielles, soll nur eine Anwendung f ...

Geschrieben von matze511 am 21.04.2024 21:42:37
Forum: PHP Developer Forum
Professioneller Webentwickler & Webdesigner

Of course, here is the translation: Hello, Thank you for your interest in the long-term project. Your extensive skills and experience in web dev ...

Geschrieben von Athelstan am 15.04.2024 09:25:39
Forum: Jobgesuche
Wir stellen unsere SEO-Agentur vor

Hallo In der heutigen digitalen Welt war es für Unternehmen noch nie so einfach, ihre Reichweite weltweit zu vergrößern. Wenn Sie außerhalb I ...

Geschrieben von thomasmuller am 14.04.2024 07:18:33
Forum: User stellen sich vor