3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UserModel { protected const DEFAULT_ALLOWED_FIELDS = [ 'username', 'status', 'status_message', 'active', 'last_active', 'deleted_at', ]; // ... other properties protected $allowedFields = self::DEFAULT_ALLOWED_FIELDS; // ... other properties } class MyModel extends UserModel { protected $allowedFields = [ ...self::DEFAULT_ALLOWED_FIELDS, 'phone_number', 'tax_id', ]; } $model = new MyModel(); $property = new ReflectionProperty($model, 'allowedFields'); $property->setAccessible(true); var_dump($property->getValue($model));
Output for 8.5.1
Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /in/I84pS on line 30 array(8) { [0]=> string(8) "username" [1]=> string(6) "status" [2]=> string(14) "status_message" [3]=> string(6) "active" [4]=> string(11) "last_active" [5]=> string(10) "deleted_at" [6]=> string(12) "phone_number" [7]=> string(6) "tax_id" }
Output for 8.5.0
Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect in /in/I84pS on line 30 array(8) { [0]=> string(8) "username" [1]=> string(6) "status" [2]=> string(14) "status_message" [3]=> string(6) "active" [4]=> string(11) "last_active" [5]=> string(10) "deleted_at" [6]=> string(12) "phone_number" [7]=> string(6) "tax_id" }
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.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14
array(8) { [0]=> string(8) "username" [1]=> string(6) "status" [2]=> string(14) "status_message" [3]=> string(6) "active" [4]=> string(11) "last_active" [5]=> string(10) "deleted_at" [6]=> string(12) "phone_number" [7]=> string(6) "tax_id" }

preferences:
159.54 ms | 412 KiB | 5 Q