eli.rodriguez
eli.rodriguez

Reputation: 490

Switch off and on warnings in php

I have an script in PHP and i want prevent that just an specific part of the code show and logs WARNINGS. something like this.

    <?php
    .....................
    .........code........
    .....................
    switch_off_warnings()
    .........code........
     switch_on_warnings()
    .....................
    .........code........
    .....................
?>

How can i achieve this ?

Upvotes: 0

Views: 113

Answers (1)

Script47
Script47

Reputation: 14540

You honestly should not be doing this, however in PHP you can suppress warnings using @. You'd simply put that before any code you want to stop showing errors.

However you should keep the following in mind:

Note: The @-operator works only on expressions. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. For instance, you can prepend it to variables, function and include calls, constants, and so forth. You cannot prepend it to function or class definitions, or conditional structures such as if and foreach, and so forth.

From the link above.

Upvotes: 2

Related Questions