3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace SQLQuery; class SQLQuery { private static $methods = array('select', 'update', 'drop', 'delete', 'create', 'alter', 'set'); private static $char_list = array( 'default' => array( 'escape' => '\\', 'quotes' => '"', 'names' => '`', 'name_separator' => '.' ), 'mysqli' => array( 'escape' => '\\', 'quotes' => '"', 'names' => '`', 'name_separator' => '.' ), 'sqlite3' => array( 'escape' => '\\', 'quotes' => '"', 'names' => '`', 'name_separator' => '.' ) ); private $chars = array(); private $type = 'unknown'; private $link = null; function __call($method, $arguments){ if(!in_array($method, self::$methods)) { throw new BadMethodCallException('Method ' . $method . ' does not exist'); } $class = __CLASS__ . ucfirst($method); return new $class($this, $this->chars, $arguments); } function __construct($link = false){ if(is_resource($link)) { $type = get_resource_type($link); if($type !== 'mysql link' || $type !== 'mysql link persistent') { throw new InvalidArgumentException('MySQL resource expected, ' . $type . ' given'); } $this->link = $link; $this->type = 'mysql'; $this->chars = self::$char_list['default']; } else if(is_object($link)) { if(class_exists('PDO') && ($link instanceof \PDO)) { $type = $link->getAttribute(\PDO::ATTR_DRIVER_NAME); } else if(class_exists('mysqli') && ($link instanceof \mysqli)) { $type = 'mysqli'; } else if(class_exists('SQLite3') && ($link instanceof \SQLite3)) { $type = 'sqlite3'; } else { throw new InvalidArgumentException('Unsupported connection type ' . get_class($link)); } $this->link = $link; $this->type = $type; $this->chars = self::$char_list[$type]; } else throw new InvalidArgumentException('Resource or Object excepted, ' . gettype($link) . ' given'); } } if(!@class_alias('SQLQuery\\SQLQuery', '\\SQLQuery')) { // very ugly hack eval('class SQLQuery extends \SQLQuery\SQLQuery{};'); } final class SQLQuerySelect { function __construct(SQLQuery $sql, array $chars, $arguments){ var_dump($chars, $arguments); } } // --------------------------------- $x = new \SQLQuery(new \mysqli()); $x->select('a');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Class "mysqli" not found in /in/IdAVJ:97 Stack trace: #0 {main} thrown in /in/IdAVJ on line 97
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Class "mysqli" not found in /in/IdAVJ:97 Stack trace: #0 {main} thrown in /in/IdAVJ on line 97
Process exited with code 255.
Output for 7.0.0 - 7.0.23, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'mysqli' not found in /in/IdAVJ:97 Stack trace: #0 {main} thrown in /in/IdAVJ on line 97
Process exited with code 255.

preferences:
154.55 ms | 402 KiB | 192 Q