Gossamer Forum
Home : General : Perl Programming :

Whats this @?

Quote Reply
Whats this @?
Hi. Just found some code at PHP.net, it is;

Code:
if(!@is_dir("/your/path")){
echo "Dir does not exist!";
mkdir("/your/path",0777);
}

What exactly does the @ do? Anyone who does PHP programming know? Why not just use;

Code:
if(!@is_dir("/your/path")){
echo "Dir does not exist!";
mkdir("/your/path",0777);
}

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Whats this @? In reply to
The @ supresses errors. So if that statement were to not find the directory, rather than php sending some php error about it not existing, you can supress that error and pront yor own, like is being done there

--mark
Quote Reply
Re: [Mark Badolato] Whats this @? In reply to
Ah cool. I can see that being quite useful. That was one of PHPs things I wasnt that keen on; not being able to define you own error messages. Not wanting to be cheeky, but I wonder if you could answer me another question. In Perl we have the $! and $@ variables for error reporting, is there a similar variable in PHP that reports the returned error?

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

AndyNewby: Dec 9, 2001, 11:25 PM
Quote Reply
Re: [AndyNewby] Whats this @? In reply to
$php_errormsg is a global variable you can use. Here's an example:
Code:
$my_file = @file ('non_existent_file') or die ("Failed opening file: error was '$php_errormsg'");
That is, if track_errors is turned on.


Adrian

Last edited by:

brewt: Dec 10, 2001, 12:39 AM
Quote Reply
Re: [brewt] Whats this @? In reply to
Thanks Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!