mercredi 4 mai 2016

laravel crashes because of undefined index?

recently i've started using laravel. but i am wondering why it crashes and throw exception because of undefined index.

for example:

$arr=[]; return $arr[1];

this causing the app to crash and return code 500. this is not good at all. i don't need it to crash, it should just return null.

How could i handle this ?

other suggest to wrap each line with isset for example:

if(isset($arr[1]))
   return $arr[1]

i can't go through all my code and wrap each line with isset. that's tough work.

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire