For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2007 > How is @ used?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How is @ used?
rog

2007-02-23, 7:01 pm

I keep running across @ used perhaps as some kind of operator.
How is it used in php syntax.
ie.
$za_dir = @dir(DIR_WS_INCLUDES . 'extra_configures')

I think this is poorly discussed/marked in the php online manual.
It's listed among the operators
~ - (int) (float) (string) (array) (object) @
and supposedly defined under the 'types' but there's no mention.

Thanks for any help,
R


Rik

2007-02-23, 7:01 pm

On Fri, 23 Feb 2007 18:09:08 +0100, rog <jk!ttop5@mnpX$.net> wrote:

> I keep running across @ used perhaps as some kind of operator.
> How is it used in php syntax.
> ie.
> $za_dir =3D @dir(DIR_WS_INCLUDES . 'extra_configures')
>
> I think this is poorly discussed/marked in the php online manual.
> It's listed among the operators
> ~ - (int) (float) (string) (array) (object) @
> and supposedly defined under the 'types' but there's no mention.


It's an error suppressor, if the following function creates an error it'=
s =

nor reported. You should almost never need this, often it's a sign of =

sloppy code when it's littered with @'s. On a live server, offcourse you=
=

don't want to display the errors to your poublic, that's why we have the=
=

setting 'display_errors', which you can set to false.

In this case, instead of:
$za_dir =3D @dir(DIR_WS_INCLUDES . 'extra_configures');

THe author should have:
if(!is_dir(DIR_WS_INCLUDES . 'extra_configures')){
//do some error handling
return false;
}
$za_dir =3D dir(DIR_WS_INCLUDES . 'extra_configures');

-- =

Rik Wasmus
rog

2007-02-23, 7:01 pm

Thanks Rik.
R



"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.tn7pywgfqnv3q9@misant...
On Fri, 23 Feb 2007 18:09:08 +0100, rog <jk!ttop5@mnpX$.net> wrote:

> I keep running across @ used perhaps as some kind of operator.
> How is it used in php syntax.
> ie.
> $za_dir = @dir(DIR_WS_INCLUDES . 'extra_configures')
>
> I think this is poorly discussed/marked in the php online manual.
> It's listed among the operators
> ~ - (int) (float) (string) (array) (object) @
> and supposedly defined under the 'types' but there's no mention.


It's an error suppressor, if the following function creates an error it's
nor reported. You should almost never need this, often it's a sign of
sloppy code when it's littered with @'s. On a live server, offcourse you
don't want to display the errors to your poublic, that's why we have the
setting 'display_errors', which you can set to false.

In this case, instead of:
$za_dir = @dir(DIR_WS_INCLUDES . 'extra_configures');

THe author should have:
if(!is_dir(DIR_WS_INCLUDES . 'extra_configures')){
//do some error handling
return false;
}
$za_dir = dir(DIR_WS_INCLUDES . 'extra_configures');

--
Rik Wasmus


عرب زواج

2007-02-23, 9:59 pm

yNPjIMfh4eUgx+HRzePkIMfh0c3t4woKCsfd1uEg
4+be2iDh4crax9HdIMjt5CAgx+HM5NMg7eQg
x+HUyMfIIObH4cjkx8og4+Qg3+Egz+bhIMfh2sfh
4wp3d3cuYXJhYnp3YWouY29tCgrI5MfKIObU
yMfIINrH7dLt7eQg7cra0d3mxyDa4e3f4woKCtXm
0SDax9HtySDN3u3e7ckKCgrK2sfR3SDjzMfk
7SDj5CDf4SDP5uEgx+Hax+HjIHd3dy5hcmFiendh
ai5jb20KICBmb3IgbWFycmlnZSBhbmQgZnJp
ZW5kIHNoaXDH3dbhIMrax9HdIMjt5CDH4dTIx8gg
5sfhyOTHyiDj5t7aINLmx8wK48zH5O0gd3d3
LmFyYWJ6d2FqLmNvbQoKd3d3LmFyYWJ6d2FqLmNv
bSDH3dbhIOPm3tog48zH5O0g4eHK2sfR3SDm
IOHh0ubHzCDH4dTR2u0KCnd3dy5hcmFiendhai5j
b20gICDI5MfKIObUyMfIINrH7dLlIMrK2tHd
INrh7d/ jCgoKCgoKdGhlIGJlc3Qgd2ViIHNpdGUgZm9ybWF
ycmlnZSBhbmQgZnJpbmRzaGlwIHd3
dy5hcmFiendhai5jb23H3dbhIOPm3toK48zH5O0g
4eHK2sfR3SDmIOHh0ubHzAo=

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com