3v4l.org

run code in 300+ PHP versions simultaneously
<?php class tokenstream { // Входной поток private $input_stream; // Указатель позиции во входном потоке public $seek = 0; // Конструктор public function __construct ( $input ) { // Инициализируем входной поток $this -> input_stream = $input; } // Возвращает очередной символ из входного потока public function readChar ( ) { $char = ( isset ( $this -> input_stream [ $this -> seek ] ) ? $this -> input_stream [ $this -> seek ] : false ); $this -> seek++; return $char; } // Производит токенизацию public function tokenize ( ) { $output = array ( ); while ( ( $char = $this -> readChar ( ) ) !== false ) { if ( preg_match ( '/\s/', $char ) ) { // Неотображаемые символы } elseif ( preg_match ( '/\"/', $char ) ) { // Кавычки $output [ ] = 'T_QUOTE'; } elseif ( условие ) { $output [ ] = 'T_...'; } } return $output; } } // Исходный код для разбора $my_source = ' function foo ( ) { $my_var = "foo-bar"; } '; // Создаем экземпляр класса парсера $tokenstream = new tokenstream ( $my_source ); // Парсим исходный код и распечатываем результат print_r ( $tokenstream -> tokenize ( ) );
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Undefined constant "условие" in /in/Z7n9p:25 Stack trace: #0 /in/Z7n9p(41): tokenstream->tokenize() #1 {main} thrown in /in/Z7n9p on line 25
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.08 ms | 401 KiB | 8 Q