3v4l.org

run code in 300+ PHP versions simultaneously
<?php class VariableStream { var $position; var $varname; function stream_open($path, $mode, $options, &$opened_path) { $url = parse_url($path); $this->varname = $url["host"]; $this->position = 0; return true; } function stream_read($count) { $p=&$this->position; $ret = substr($GLOBALS[$this->varname], $p, $count); $p += strlen($ret); return $ret; } function stream_write($data){ $v=&$GLOBALS[$this->varname]; $l=strlen($data); $p=&$this->position; $v = substr($v, 0, $p) . $data . substr($v, $p += $l); return $l; } function stream_stat(){ $v=&$GLOBALS[$this->varname]; return array( -1, /*dev*/ 0, /*ino*/ 0, /*mode*/ 1, /*nlink*/ 0, /*uid*/ 0, /*gid*/ 0, /*rdev*/ strlen($v), /*size*/ 0, /*atime*/ 0, /*mtime*/ 0, /*ctime*/ -1, /*blksize*/ -1, /*blocks*/); } function stream_tell() { return $this->position; } function stream_eof() { return $this->position >= strlen($GLOBALS[$this->varname]); } function stream_seek($offset, $whence) { $l=strlen($GLOBALS[$this->varname]); $p=&$this->position; switch ($whence) { case SEEK_SET: $newPos = $offset; break; case SEEK_CUR: $newPos = $p + $offset; break; case SEEK_END: $newPos = $l + $offset; break; default: return false; } $ret = ($newPos >=0 && $newPos <=$l); if ($ret) $p=$newPos; return $ret; } } stream_wrapper_register("var", "VariableStream") or die("Failed to register protocol"); function test_parse($lang) { global $inivar; $inivar = 'standard_lang='.$lang; $arr = parse_ini_file('var://inivar'); var_dump($arr['standard_lang']); } test_parse('en'); test_parse('de'); test_parse('no'); test_parse('es'); test_parse('yes');
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.17, 8.5.0 - 8.5.2
Deprecated: Creation of dynamic property VariableStream::$context is deprecated in /in/YJRCT on line 69 Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(2) "en" Deprecated: Creation of dynamic property VariableStream::$context is deprecated in /in/YJRCT on line 69 Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(2) "de" Deprecated: Creation of dynamic property VariableStream::$context is deprecated in /in/YJRCT on line 69 Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(0) "" Deprecated: Creation of dynamic property VariableStream::$context is deprecated in /in/YJRCT on line 69 Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(2) "es" Deprecated: Creation of dynamic property VariableStream::$context is deprecated in /in/YJRCT on line 69 Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(1) "1"
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34
Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(2) "en" Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(2) "de" Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(0) "" Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(2) "es" Warning: parse_ini_file(): VariableStream::stream_set_option is not implemented! in /in/YJRCT on line 69 string(1) "1"
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
string(2) "en" string(2) "de" string(0) "" string(2) "es" string(1) "1"
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/YJRCT on line 4 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/YJRCT on line 5 string(2) "en" string(2) "de" string(0) "" string(2) "es" string(1) "1"
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Warning: parse_ini_file(): Cannot open 'var://inivar' for reading in /in/YJRCT on line 69 NULL Warning: parse_ini_file(): Cannot open 'var://inivar' for reading in /in/YJRCT on line 69 NULL Warning: parse_ini_file(): Cannot open 'var://inivar' for reading in /in/YJRCT on line 69 NULL Warning: parse_ini_file(): Cannot open 'var://inivar' for reading in /in/YJRCT on line 69 NULL Warning: parse_ini_file(): Cannot open 'var://inivar' for reading in /in/YJRCT on line 69 NULL
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: stream_wrapper_register() in /in/YJRCT on line 62

preferences:
202.9 ms | 416 KiB | 5 Q