note 87026 added to language.operators.logical

From: Date: Sat, 15 Nov 2008 09:51:15 +0000
Subject: note 87026 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-146579@lists.php.net to get a copy of this message
Dear sandaimespaceman at gmail dot com You are putting some really, really bad practice into use here! die() and exit(); kill your script! Which in most cases should be avoided as much as possible. It does not provide any advantages whatsoever! Even worse is suppressing errors with @ unless you can replicate the errors yourself. However your example is horrible! Let's take a look at http://www.php.net/mysql_connect it says at the return values: "Returns a MySQL link identifier on success, or FALSE on failure. " I assume you want to know what went wrong if the connection fails, so you can fix it. <?php $connection = @mysql_connect($host, $user, $pass); if(!$connection){ echo 'connection failed: '.mysql_errno($connection).' => '.mysql_error($connection).'<br />'.PHP_EOL; } else{ //connected, proceed! } ?> Hence you get a message instead of killing your complete application and wondering where it all went wrong.... Very bad practice to use exit() or die here! This is more related to mysql_connect then Logical Operators by the way. Admins should remove your post IMO. ---- Server IP: 213.249.64.162 Probable Submitter: 94.210.32.223 ---- Manual Page -- http://www.php.net/manual/en/language.operators.logical.php Edit -- https://master.php.net/note/edit/87026 Del: integrated -- https://master.php.net/note/delete/87026/integrated Del: useless -- https://master.php.net/note/delete/87026/useless Del: bad code -- https://master.php.net/note/delete/87026/bad+code Del: spam -- https://master.php.net/note/delete/87026/spam Del: non-english -- https://master.php.net/note/delete/87026/non-english Del: in docs -- https://master.php.net/note/delete/87026/in+docs Del: other reasons-- https://master.php.net/note/delete/87026 Reject -- https://master.php.net/note/reject/87026 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146579) next »