PHP - know offset error

Asked

Viewed 241 times

1

Is there a variable that shows if there is an offset error in php, but without displaying on the screen ? like a function that evaluates ? Thank you

  • 1

    Usually you do a test with the isset(), if(isset($arr['index']){ ...

  • Currently use &$array[$key]. But I recommend using the isset()

  • Isn’t there something that checks if it will print on the screen ? like a log function that I can check ?

  • What is the specific error you want to avoid? Non-existent array element? Puts more information that makes it easier to help.

  • Notice: Undefined offset: 8 this is the error

1 answer

2


It would be like this, it would show in the logs and on the screen would not display:

ini_set('display_errors',0);
ini_set('display_startup_erros',0);
error_reporting(E_ALL);

if you replace 0(zero) with 1, it will show on the screen as well.

  • But what to check on an if ? type if($existeerro == true {} How would you do ?

  • The correct one is you develop showing all the errors and treat this before because you want to check if there is an error in an if?

  • because there is a case that I need to redirect, to a second way to be done like if error = 0 ok if error method2

  • So I think it would be something like @rray quoted above: if(! isset($arr['index']){} denying isset.

  • but it is not always that the error occurs ...

  • put some example of your code, so we can better understand what you want.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.