Search code examples
phpsettingsphp-iniini-set

What difference does usage of symbol @ with ini_set, built-in function makes in PHP?


In one of my project's configuration settings I observed following two lines at the beginning of file :

@ini_set('memory_limit', '-1');
@set_time_limit(0);

My doubt is what's the difference in the above two lines of code and following lines of code?

ini_set('memory_limit', '-1');
set_time_limit(0);

What's the intention of prefixing @ symbol in PHP?

Please provide me in detail and to the point answer.

Thanks in advance.


Solution

  • @ in php is simply for silencing errors.

    for example:

    <?php
        $x = 5;
        $y = @$z;
    

    so $y will be null

    if you remove the @ it will throw an error.