Array to string conversion
in latest versions of php 7.x is error, rather than notice, and prevents further code execution.
Using print
, echo
on array is not an option anymore.
Suppressing errors and notices is not a good practice, especially when in development environment and still debugging code.
Use var_dump
,print_r
, iterate through input value using foreach
or for
to output input data for names that are declared as input arrays ('name[]
')
Most common practice to catch errors is using try/catch
blocks, that helps us prevent interruption of code execution that might cause possible errors wrapped within try
block.
try{ //wrap around possible cause of error or notice
if(!empty($_POST['C'])){
echo $_POST['C'];
}
}catch(Exception $e){
//handle the error message $e->getMessage();
}