3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $formerrors = array(); $formdata = array( 'first_name' => 'Tester', 'last_name' => 'Dev', 'company' => 'BobCAD', 'email' => 'no-reply@bobcad.com', 'phone' => '555-555-5555', 'country' => 'US', 'state' => 'FL', 'is_customer' => 'Yes', 'is_sw_customer' => 'No' ); foreach ($formdata as $key => &$value) { if (!empty($_POST[$key])) { $value = $_POST[$key]; } } unset($key, $value); echo "org".PHP_EOL; print_r($formdata).PHP_EOL.PHP_EOL; // Check Phone if (preg_match('/\d+/', str_replace(array('-', '(', ')', '.', ' '), '', $formdata['phone']))) { $formerrors[] = 'Please enter a valid phone number'; $formdata['phone'] = ''; } // Check Email if (preg_match('/\A[a-z0-1\-\._]+@[a-z0-1\-\.]+\Z/i', $formdata['email'])) { $formerrors[] = 'Please enter a valid email'; $formdata['email'] = ''; } // Check first_name if(empty($formdata['first_name'])) { $formerrors[] = 'Please enter a first name'; $formdata['first_name'] = ''; } // Check last_name if(empty($formdata['last_name'])) { $formerrors[] = 'Please enter a last name'; $formdata['last_name'] = ''; } // Check company if(empty($formdata['company'])) { $formerrors[] = 'Please enter a company'; $formdata['company'] = ''; } // Check country if(empty($formdata['country'])) { $formerrors[] = 'Please enter a country'; $formdata['country'] = ''; } // Check state if(empty($formdata['state'])) { $formerrors[] = 'Please enter a state'; $formdata['state'] = ''; } echo "checked".PHP_EOL; print_r($formdata).PHP_EOL.PHP_EOL;
based on CIsTK
Output for 5.0.2 - 7.2.0
org Array ( [first_name] => Tester [last_name] => Dev [company] => BobCAD [email] => no-reply@bobcad.com [phone] => 555-555-5555 [country] => US [state] => FL [is_customer] => Yes [is_sw_customer] => No ) checked Array ( [first_name] => Tester [last_name] => Dev [company] => BobCAD [email] => [phone] => [country] => US [state] => FL [is_customer] => Yes [is_sw_customer] => No )
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uWscG on line 23 orgPHP_EOLArray ( [first_name] => Tester [last_name] => Dev [company] => BobCAD [email] => no-reply@bobcad.com [phone] => 555-555-5555 [country] => US [state] => FL [is_customer] => Yes [is_sw_customer] => No ) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uWscG on line 24 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uWscG on line 24 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uWscG on line 68 checkedPHP_EOLArray ( [first_name] => Tester [last_name] => Dev [company] => BobCAD [email] => [phone] => [country] => US [state] => FL [is_customer] => Yes [is_sw_customer] => No ) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uWscG on line 69 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uWscG on line 69
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/uWscG on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/uWscG on line 16
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/uWscG on line 16
Process exited with code 255.