3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 7.1.0
Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Warning: Illegal string offset 'state' in /in/onXdG on line 23 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'zone' in /in/onXdG on line 26 Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Warning: Illegal string offset 'state' in /in/onXdG on line 23 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'zone' in /in/onXdG on line 26 Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Warning: Illegal string offset 'state' in /in/onXdG on line 23 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'zone' in /in/onXdG on line 26 Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Warning: Illegal string offset 'state' in /in/onXdG on line 23 Warning: Cannot assign an empty string to a string offset in /in/onXdG on line 23 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'zone' in /in/onXdG on line 26 {"error":"P"}
Output for 5.4.0 - 7.0.14
Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Warning: Illegal string offset 'state' in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Warning: Illegal string offset 'zone' in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 {"error":{"state":null,"zone":"Please select a city \/ area!"}}
Output for 5.3.0 - 5.3.29
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 {"error":{"state":null,"zone":"Please select a city \/ area!"}}
Output for 5.2.10 - 5.2.17
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 {"error":{"state":null,"zone":"Please select a city \/ area!"}}
Output for 5.2.0 - 5.2.9
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 {"error":{"state":null,"zone":"Please select a city \/ area!"}}
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.6
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Fatal error: Call to undefined function json_encode() in /in/onXdG on line 36
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/onXdG on line 37
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Fatal error: Call to undefined function: json_encode() in /in/onXdG on line 36
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Fatal error: Call to undefined function: json_encode() in /in/onXdG on line 36
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Notice: Uninitialized string offset: 0 in /in/onXdG on line 22 Notice: Undefined index: postcode_required in /in/onXdG on line 23 Notice: Uninitialized string offset: 0 in /in/onXdG on line 25 Fatal error: Call to undefined function: json_encode() in /in/onXdG on line 36