php - Can I continue coding if ($a[undefined]) as false? -
i wonder code has security risk or etc?
this code cause notice error.
<?php $array = array(); if ($array['hoge']) { } ?>
and set ~e_notice in php.ini.
should use empty()?
thank you.
the notice error caused because checking if $array['hoge'] either true or false, when in fact value isn't set. correct way code previous if conditional be:
<?php $array = array(); if !empty($array['hoge']) { //...code executed inside conditional... } ?>
it practice check if array both set , if it's not empty. hope helps! :)
Comments
Post a Comment