1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Why Using @ When Using mkdir() ?

Discussion in 'Development' started by Hoyee, Dec 27, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    why? and if I don't use @, What Happens?

    example : @mkdir ($this->getDataFolder());
     
  2. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    The @ ignores any error message made by the mkdir() function or any other function https://www.php.net/manual/en/language.operators.errorcontrol.php
    mkdir() will throw an error if the directory exist or if the permission was denied
    if you remove it, (you guessed it) any error made by the function won't be ignored
    btw why tf do people still do @mkdir($this->getDataFolder());
     
  3. Mohagames205

    Mohagames205 Spider Jockey

    Messages:
    26
    GitHub:
    mohagames205
    The @ supresses any warning and errors that might be generated. You can read more about it right here:
    https://www.php.net/manual/en/language.operators.errorcontrol.php

    from the PHP website ^^

    (GG @mmm545 for being earlier xD)
     
    mmm545 and Primus like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.