3v4l.org

run code in 300+ PHP versions simultaneously
<?php $state_id = ''; $zone_id = ''; $postcode = ''; $postcode_required = ''; function validate($state_id,$zone_id,$postcode,$postcode_required) { $message = array( 'warning' => 'Warning: No Shipping options are available. Please contact us for assistance!', 'state' => 'Please select a state!', 'zone' => 'Please select a city / area!', 'postcode' => 'Postcode must be between 4 and 10 characters!' ); $delivery_quites = array('state' => $state_id, 'zone' =>$zone_id, 'postcode'=>$postcode, 'postcode_required'=>$postcode_required ); $data = ''; foreach($delivery_quites as $key => $value){ if ($value['state'] ===''){ $data['state'] = $message[$key]; } if ($value['zone'] ==''){ $data['zone'] = $message['zone']; } } return $data; } $test = validate($state_id,$zone_id,$postcode,$postcode_required); print_r(json_encode(array('error' => $test))); //print_r($delivery_quites);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/vGJ3c:22 Stack trace: #0 /in/vGJ3c(35): validate('', '', '', '') #1 {main} thrown in /in/vGJ3c on line 22
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.4 ms | 401 KiB | 8 Q