Please see the below code this is work perfectly in PHP. Can anyone explain me how this code works. Because in the below code i have declared
without semicolon and without any value deceleration. Then also this code work perfectly without any error and
var_dump($category_id) returns me an
How php execute this code without semicolon??
$category_id= //No semicolon
var_dump($category_id); //returns NULL
It works because PHP treats your code like this:
$category_id = var_dump($category_id);
The return value of
var_dump() gets assigned to
$category_id. Undefined variables in PHP are implicitly set to
null, which is what you see in the output of
var_dump(). However, you would also get a notice about
$category_id not being defined; if you don't see it, you should use this code in your script:
error_reporting(-1); ini_set('display_errors', 'On');
These settings are also recommended during development as they can catch issues that would otherwise have gone unnoticed on a production machine.