Why @ character before a function call in php ?

Every php native functions have some return value or changes in actual values so return value type may be Error || Warning || Fatal Error so to prevent and run the remaining code without any interruption. in short @ character will not throw any errors.

i am writing this post because of following reason.

  • i need to print image from remote server s3 if available or print any dummy image.
  • i checked if image url source available then use & print but some remote url not reachable to produce image or limited forbidden access then your image wont come event exist on remote server.
  • Solution i used getimagesize() php standard method, mostly this method returns array of image attributes but url is forbidden then produces the warning so to avoid the php warnings just put @ sing before function call like @getImagesize($url)  it will silent all php errors.

About Hiren Kubavat

This entry was posted in PHP. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s