Re: Scripts getting by in php7 but chokes in php8
"J.O. Aho" <[email protected]>
| Newsgroups | comp.lang.php |
|---|---|
| Message-ID | <[email protected]> |
On 03/12/2022 03.44, The Doctor wrote: > Here are a couple of scripts that are working in php7 but choke in php8 Too much code for usergroup posts, give a link to your git repository instead, if you don't have one, gitlab and github offers you some space for free. > In the error log we are seeing > > 2022/12/01 08:26:20 [error] 51954#102104: *266090 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: sessionid in /path/to/step2.php on line 30PHP message: PHP Warning: Use of undefined constant charge_total - assumed 'charge_total' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 33PHP message: PHP Warning: Use of undefined constant bill_first_name - assumed 'bill_first_name' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 35PHP message: PHP Warning: Use of undefined constant bill_last_name - assumed 'bill_last_name' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 36PHP message: PHP Warning: Use of undefined constant bill_company_name - assumed 'bill_company_name' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 37PHP message: PHP Warning: Use of undefined constant bill_address_one - assumed 'bill_address_one' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 38PHP message: PHP Warning: Use of undefined constant bill_city - assumed 'bill_city' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 39PHP message: PHP Warning: Use of undefined constant bill_state_or_province - assumed 'bill_state_or_province' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 40PHP message: PHP Warning: Use of undefined constant bill_postal_code - assumed 'bill_postal_code' (this will throw an Error in a future version of PHP) in /path/to/step2.php on line 41PHP message: PHP Warning: Use of undefined constant bill_phone - assumed 'bill_phone' (this will throw an Error in a future version of PHP) in /usr/local/www/n Seems to be the classic issue of not declaring variables/constants ahead of use. Please try to follow C/C++ coding standard. > 2022/12/02 10:44:29 [error] 51954#102104: *557026 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "sessionid" in /path/to/step2.php on line 30PHP message: PHP Fatal error: Uncaught Error: Undefined constant "charge_total" in /path/to/step2.php:33 try/catch is a good way of handling issues that arises when you can't check if value exists or not before use. > What pointers for fixes? Always be sure the value exists before you use it. -- //Aho