Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

What does the '@' do?

homerocdahomerocda Posts: 87Member
Hello,

I've seen some php scripts around there that uses an @ symbol in front of some function calls. I would like to know what does it do and why to use it.

Thanks.

Homero C. de Almeida

[italic]There's no dishonour in failure. For we aren't allowed to know wheter we'll achieve success or not. There is only one final shame, the cowardice of not trying.[/italic]

Comments

  • tvientitvienti Posts: 230Member
    It's hard to find documention on php.net for some of the more basic features of PHP. I can't seem to find [i]any[/i] official documentation of this one. Anyhow, I believe @ supresses any non-fatal errors (warnings, notices).

    [code]
    $fh = @fopen('/this/file/doesnt/exist', 'r'); /* nobody will see this error */
    [/code]

    T

    : Hello,
    :
    : I've seen some php scripts around there that uses an @ symbol in front of some function calls. I would like to know what does it do and why to use it.
    :
    : Thanks.
    :
    : Homero C. de Almeida
    :
    : [italic]There's no dishonour in failure. For we aren't allowed to know wheter we'll achieve success or not. There is only one final shame, the cowardice of not trying.[/italic]
    :

  • homerocdahomerocda Posts: 87Member
    Yeah, I haven't found anything about it either, so I posted here... But what an tricky operator, isn't it? An operator for cheating on errors, oh Lord... :-)

    : It's hard to find documention on php.net for some of the more basic features of PHP. I can't seem to find [i]any[/i] official documentation of this one. Anyhow, I believe @ supresses any non-fatal errors (warnings, notices).
    :
    : [code]
    : $fh = @fopen('/this/file/doesnt/exist', 'r'); /* nobody will see this error */
    : [/code]
    :
    : T
    :

  • tvientitvienti Posts: 230Member
    It's good that you caught that :) To me @ seems like the poor-man's error handling, maybe why it's so obscurely documented (if at all). I never use it.

    : Yeah, I haven't found anything about it either, so I posted here... But what an tricky operator, isn't it? An operator for cheating on errors, oh Lord... :-)
    :
    : : It's hard to find documention on php.net for some of the more basic features of PHP. I can't seem to find [i]any[/i] official documentation of this one. Anyhow, I believe @ supresses any non-fatal errors (warnings, notices).
    : :
    : : [code]
    : : $fh = @fopen('/this/file/doesnt/exist', 'r'); /* nobody will see this error */
    : : [/code]
    : :
    : : T
    : :
    :
    :

Sign In or Register to comment.