3v4l.org

run code in 300+ PHP versions simultaneously
<?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;
Output for 5.0.2 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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.3.11, 4.4.0 - 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.

preferences:
327.57 ms | 401 KiB | 459 Q