3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = array( 'gid'=>1, 'phone_number'=>1, 'weibo'=>1, 'qq'=>1, 'email'=>1, 'gender'=>1, 'age'=>1, 'area'=>1, 'computer'=>1, 'phone'=>1, 'valid_user'=>1, 'bank'=>json_encode(array(1,2,3)), 'tag_big'=>json_encode(array(1,2,3)), 'tag_medium'=>json_encode(array(1,2,3)), 'tag_small'=>json_encode(array(1,2,3)), 'family'=>json_encode(array(1,2,3)), 'friend'=>json_encode(array(1,2,3)), 'visitor'=>json_encode(array(1,2,3)) ); $field = array( 'gid', 'phone_number', 'weibo', 'qq', 'email', 'gender', 'age', 'area', 'computer', 'phone', 'valid_user', 'bank', 'tag_big', 'tag_medium', 'tag_small', 'family', 'friend', 'visitor' ); function constructPortrait(ValueAddedParams $params){ $retPortraitArr = array(); $portraitArr = json_decode($params->getUserPortraitInfo(), true); $fields = ValueAdded::$FIELDS; foreach($portraitArr as $key => $portrait){ foreach($fields as $field){ $retPortraitArr[$key][$field] = isset($portrait[$key]) && !empty($portrait[$key]) ? $portrait[$key] : ''; } } return $retPortraitArr; } echo json_encode(constructPortrait($field, $test));
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 TypeError: constructPortrait(): Argument #1 ($params) must be of type ValueAddedParams, array given, called in /in/CoXoF on line 35 and defined in /in/CoXoF:20 Stack trace: #0 /in/CoXoF(35): constructPortrait(Array, Array) #1 {main} thrown in /in/CoXoF on line 20
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 TypeError: constructPortrait(): Argument #1 ($params) must be of type ValueAddedParams, array given, called in /in/CoXoF on line 35 and defined in /in/CoXoF:20 Stack trace: #0 /in/CoXoF(35): constructPortrait(Array, Array) #1 {main} thrown in /in/CoXoF on line 20
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to constructPortrait() must be an instance of ValueAddedParams, array given, called in /in/CoXoF on line 35 and defined in /in/CoXoF:20 Stack trace: #0 /in/CoXoF(35): constructPortrait(Array, Array) #1 {main} thrown in /in/CoXoF on line 20
Process exited with code 255.
Output for 5.5.0 - 5.5.37, 5.6.0 - 5.6.28
Catchable fatal error: Argument 1 passed to constructPortrait() must be an instance of ValueAddedParams, array given, called in /in/CoXoF on line 35 and defined in /in/CoXoF on line 20
Process exited with code 255.

preferences:
178.48 ms | 402 KiB | 251 Q