3v4l.org

run code in 300+ PHP versions simultaneously
<?php // returns true if property is safely accessible publicly by using $obj->$prop: function public_property_exists( $obj, $prop ){ // allow magic $obj->__isset( $prop ) to execute if exists if( isset( $obj->$prop )) return true; // no public/protected/private property exists with this name if( ! property_exists( $obj, $prop )) return false; // the property exists, but is it public? $rp = new ReflectionProperty( $obj, $prop ); return $rp->isPublic(); } class C { public $public = "I’m public!"; protected $protected = "I’m public!"; private $private = "I’m public!"; function __isset( $k ){ return substr( $k, 0, 5 ) === 'magic'; } function __get( $k ){ if( $k === 'magic_isset_but_null') return null; return "I’m {$k}!"; } } $o = new C(); foreach( array( 'public', 'protected', 'private', 'magic', 'magic_isset_but_null', 'missing' ) as $prop ){ if( public_property_exists( $o, $prop )) echo "\$o->{$prop} is a public property, its value is: ", var_export( $o->$prop, true ), "\n"; else echo "\$o->{$prop} is not a public property.\n"; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.70.0170.00316.63
8.3.60.0090.00618.55
8.3.50.0140.00718.26
8.3.40.0090.00622.05
8.3.30.0090.00623.56
8.3.20.0000.00724.18
8.3.10.0040.00424.66
8.3.00.0040.00525.07
8.2.180.0070.01316.50
8.2.170.0120.00318.79
8.2.160.0130.00722.96
8.2.150.0040.00825.66
8.2.140.0040.00424.66
8.2.130.0070.00225.07
8.2.120.0080.00021.76
8.2.110.0060.00321.67
8.2.100.0070.00320.81
8.2.90.0090.00520.60
8.2.80.0090.00420.51
8.2.70.0140.00120.48
8.2.60.0110.00420.47
8.2.50.0100.00721.05
8.2.40.0070.00520.97
8.2.30.0110.00220.42
8.2.20.0100.00420.44
8.2.10.0070.00620.55
8.2.00.0120.00220.64
8.1.280.0140.00725.92
8.1.270.0060.00323.04
8.1.260.0070.00125.17
8.1.250.0030.00926.04
8.1.240.0100.00320.35
8.1.230.0080.00620.30
8.1.220.0080.00520.39
8.1.210.0080.00521.27
8.1.200.0090.00420.30
8.1.190.0060.00520.27
8.1.180.0110.00320.32
8.1.170.0100.00420.38
8.1.160.0120.00120.43
8.1.150.0060.00621.60
8.1.140.0080.00620.34
8.1.130.0060.00720.36
8.1.120.0110.00320.41
8.1.110.0090.00420.38
8.1.100.0100.00420.33
8.1.90.0060.00720.28
8.1.80.0100.00320.38
8.1.70.0090.00220.41
8.1.60.0090.00620.45
8.1.50.0090.00420.41
8.1.40.0080.00520.41
8.1.30.0080.00520.60
8.1.20.0100.00420.48
8.1.10.0020.01020.55
8.1.00.0070.00521.00
8.0.300.0110.00319.91
8.0.290.0120.00420.46
8.0.280.0110.00219.85
8.0.270.0100.00419.84
8.0.260.0150.00120.43
8.0.250.0080.00619.97
8.0.240.0100.00619.93
8.0.230.0110.00320.15
8.0.220.0110.00419.94
8.0.210.0110.00319.87
8.0.200.0130.00219.84
8.0.190.0080.00519.86
8.0.180.0100.00219.93
8.0.170.0090.00519.93
8.0.160.0100.00419.83
8.0.150.0110.00319.90
8.0.140.0140.00219.78
8.0.130.0100.00220.13
8.0.120.0110.00419.82
8.0.110.0090.00319.97
8.0.100.0120.00319.82
8.0.90.0130.00319.75
8.0.80.0070.00820.44
8.0.70.0110.00220.48
8.0.60.0110.00519.83
8.0.50.0140.00219.79
8.0.30.0110.00219.89
8.0.20.0100.00419.87
8.0.10.0130.00119.89

preferences:
49.81 ms | 400 KiB | 5 Q