3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class db extends PDO { private $engine; private $host; private $database; private $user; private $pass; private $charset; private static $link = null ; public static $VirtualDeletion = array( 'on' => false, 'Field' => '', 'Value' => '' ); public function __construct() { return self::i(); } public static function i() { if (!self::$link) return self::$link; $this->engine = 'mysql'; $this->host = 'localhost'; $this->database = ''; $this->user = 'root'; $this->pass = ''; $this->charset = 'utf8'; $dsn = $this->engine .":dbname=". $this->database .";charset=". $this->charset .";host=". $this->host; self::$link = parent::__construct( $dsn, $this->user, $this->pass ); /* PHP < 5.3.6 self::$link->exec("set names utf8"); */ return self::$link; } public function __destruct() { if(self::$link) { /* Estudar as implicações disto: if(PDO::inTransaction()) self::$link->commit(); */ self::$link = null; } } } /* ###### config.ini ###### db_driver=mysql db_user=root db_password=924892xp [dsn] host=localhost port=3306 dbname=localhost [db_options] PDO::MYSQL_ATTR_INIT_COMMAND=set names utf8 [db_attributes] ATTR_ERRMODE=ERRMODE_EXCEPTION ############ private static function getLink ( ) { if ( self :: $link ) { return self :: $link ; } $ini = _BASE_DIR . "config.ini" ; $parse = parse_ini_file ( $ini , true ) ; $driver = $parse [ "db_driver" ] ; $dsn = "${driver}:" ; $user = $parse [ "db_user" ] ; $password = $parse [ "db_password" ] ; $options = $parse [ "db_options" ] ; $attributes = $parse [ "db_attributes" ] ; foreach ( $parse [ "dsn" ] as $k => $v ) { $dsn .= "${k}=${v};" ; } self :: $link = new PDO ( $dsn, $user, $password, $options ) ; foreach ( $attributes as $k => $v ) { self :: $link -> setAttribute ( constant ( "PDO::{$k}" ) , constant ( "PDO::{$v}" ) ) ; } return self :: $link ; } public static function __callStatic ( $name, $args ) { $callback = array ( self :: getLink ( ), $name ) ; return call_user_func_array ( $callback , $args ) ; } */ ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OmDg6
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  121     0  E > > RETURN                                                   1

Class db:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OmDg6
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_STATIC_METHOD_CALL                                  'i'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   24     3*     > RETURN                                                   null

End of function __construct

Function i:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OmDg6
function name:  i
number of ops:  54
compiled vars:  !0 = $dsn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_STATIC_PROP_R          unknown             ~1      'link'
          1        BOOL_NOT                                         ~2      ~1
          2      > JMPZ                                                     ~2, ->5
   29     3    >   FETCH_STATIC_PROP_R          unknown             ~3      'link'
          4      > RETURN                                                   ~3
   31     5    >   FETCH_THIS                                       $4      
          6        ASSIGN_OBJ                                               $4, 'engine'
          7        OP_DATA                                                  'mysql'
   32     8        FETCH_THIS                                       $6      
          9        ASSIGN_OBJ                                               $6, 'host'
         10        OP_DATA                                                  'localhost'
   33    11        FETCH_THIS                                       $8      
         12        ASSIGN_OBJ                                               $8, 'database'
         13        OP_DATA                                                  ''
   34    14        FETCH_THIS                                       $10     
         15        ASSIGN_OBJ                                               $10, 'user'
         16        OP_DATA                                                  'root'
   35    17        FETCH_THIS                                       $12     
         18        ASSIGN_OBJ                                               $12, 'pass'
         19        OP_DATA                                                  ''
   36    20        FETCH_THIS                                       $14     
         21        ASSIGN_OBJ                                               $14, 'charset'
         22        OP_DATA                                                  'utf8'
   38    23        FETCH_THIS                                       $16     
         24        FETCH_OBJ_R                                      ~17     $16, 'engine'
         25        CONCAT                                           ~18     ~17, '%3Adbname%3D'
         26        FETCH_THIS                                       $19     
         27        FETCH_OBJ_R                                      ~20     $19, 'database'
         28        CONCAT                                           ~21     ~18, ~20
         29        CONCAT                                           ~22     ~21, '%3Bcharset%3D'
         30        FETCH_THIS                                       $23     
         31        FETCH_OBJ_R                                      ~24     $23, 'charset'
         32        CONCAT                                           ~25     ~22, ~24
         33        CONCAT                                           ~26     ~25, '%3Bhost%3D'
         34        FETCH_THIS                                       $27     
         35        FETCH_OBJ_R                                      ~28     $27, 'host'
         36        CONCAT                                           ~29     ~26, ~28
         37        ASSIGN                                                   !0, ~29
   40    38        INIT_STATIC_METHOD_CALL                                  
         39        SEND_VAR_EX                                              !0
         40        CHECK_FUNC_ARG                                           
         41        FETCH_THIS                                       $32     
         42        FETCH_OBJ_FUNC_ARG                               $33     $32, 'user'
         43        SEND_FUNC_ARG                                            $33
         44        CHECK_FUNC_ARG                                           
         45        FETCH_THIS                                       $34     
         46        FETCH_OBJ_FUNC_ARG                               $35     $34, 'pass'
         47        SEND_FUNC_ARG                                            $35
         48        DO_FCALL                                      0  $36     
         49        ASSIGN_STATIC_PROP                                       'link'
         50        OP_DATA                                                  $36
   45    51        FETCH_STATIC_PROP_R          unknown             ~37     'link'
         52      > RETURN                                                   ~37
   46    53*     > RETURN                                                   null

End of function i

Function __destruct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
filename:       /in/OmDg6
function name:  __destruct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'link'
          1      > JMPZ                                                     ~0, ->4
   58     2    >   ASSIGN_STATIC_PROP                                       'link'
          3        OP_DATA                                                  null
   62     4    > > RETURN                                                   null

End of function __destruct

End of class db.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.03 ms | 1399 KiB | 13 Q