Jump to content

Recommended Posts

Hey,

 

 

I recently been learning some php scripts for a engine i am creating, and i am seeing this in some of the example scripts:

 

 

if (!@$user['id']) {
		GLOBAL $wrongPass;
		$wrongPass = true;
		return false;
	}

 

 

I'm familiar with PHP but i have never seen the @ symbol before. It seems to make no difference if i remove it =/

 

 

What does it actually do for the if statement, does it make it case insensitive or something?

Link to comment
https://forums.phpfreaks.com/topic/257288-what-does-the-mean/
Share on other sites

Safe, yes. Bad coding, yes.  What happens when you change your database connection variable to $conn.  You have just broken that function.  Now not a big deal if the function resides in the current script you are working in.  However, what if it resides in a file that was included?

 

In your script though, the global is not even needed, since you are working in a class.  $db is a variable of the class, so it can be used as $this->db (and it is).

Link to comment
https://forums.phpfreaks.com/topic/257288-what-does-the-mean/#findComment-1318829
Share on other sites

I've experienced at least one time where it has been a good idea to use it...

 

I wanted to do something to a dynamic file. I did check the file extension and the mime, but it still could end in error if there was something wrong with the file, which I've seen happen without somebody doing it on purpose (images btw). The function would return an error if it failed, but I didn't want it to output this error, but instead do something else. I believe I did something like this, if(@$variable=function($file)), to make it do what I wanted to.

 

The point is anyways that there are cases where it could be useful. Same where when a function if it fails could show sensitive information you don't want anyone to see.

 

Also, I'm not saying this guy have used GLOBAL and @ wisely.

Link to comment
https://forums.phpfreaks.com/topic/257288-what-does-the-mean/#findComment-1318836
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.