3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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));
based on tiAOI
Output for 7.0.0 - 7.2.0
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.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.