whats the @ for

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PHPForever
Forum Newbie
Posts: 14
Joined: Sun Aug 31, 2008 11:31 am

whats the @ for

Post by PHPForever »

mkdir and @mkdir - can anyone explain the difference ?

I ran a PHP script with both and they do the same thing.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: whats the @ for

Post by VladSun »

It's not a Linux related question, but a PHP related one.

http://www.faqts.com/knowledge_base/vie ... 068/fid/38
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: whats the @ for

Post by pickle »

Moving to PHP-Code
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: whats the @ for

Post by greyhoundcode »

If you place an @ symbol in front of a command then it suppresses error messages. For example:

Code: Select all

if (!@mkdir($userGeneratedString))
{
   echo 'The directory could not be created :-( ';
}
Now, if for some reason $userGeneratedString equals a load of gibberish like dsds££>:;4, instead of getting a PHP generated error message you can produce your own, or attempt to handle the error in some way.
PHPForever
Forum Newbie
Posts: 14
Joined: Sun Aug 31, 2008 11:31 am

Re: whats the @ for

Post by PHPForever »

Got it. thanks.
Post Reply