Tip: Suppress error messages in PHP

In some cases the standard error messages from PHP reveal secure information about the environment. That information could help a malicious user in getting control of your server. Have a look at the following code, which builds a connection with mysql server.

<?
	@mysql_connect("localhost","root","") or 
		die("The webiste is under a usual maintenance, please check back soon!");
	@mysql_select_db("db1") or
		die("The webiste is under a usual maintenance, please check back soon");
 ?>

The @ symbol in front of above two functions prevent PHP from displaying the standard error message

You as a programmer should take care of many other functions of PHP ( especially the functions which request for some resource like file system functions), which can reveal environment related information to malicious users.

 

More PHP tips