note 66481 added to function.socket-clear-error

From: Date: Tue, 23 May 2006 23:08:13 +0000
Subject: note 66481 added to function.socket-clear-error
Groups: php.notes 
Request: Send a blank email to php-notes+get-111907@lists.php.net to get a copy of this message
If you want to clear your error in a small amount of code, do a similar hack as to what most people do in SQL query checking, <?php $result = mysql_query($sql) or die(/* Whatever code */); ?> It could look like this: <?php if (!($socket = socket_create(/* Whatever code */)) { echo ("Failed to create socket: " . socket_strerror(socket_last_error()) and socket_clear_error()); } ?> As you can see, I use "and" here instead of "or" since the first part will always return true, thus if you use or PHP's lazy boolean checking will not execute the last part, which it will with an and if the first part is true. ---- Server IP: 193.27.201.10 (proxied: 193.27.201.10 1.0 www1.shellkonto.se:3128 (squid/2.5.STABLE4)) Probable Submitter: 80.217.189.158 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.socket-clear-error.php Edit -- http://master.php.net/note/edit/66481 Del: integrated -- http://master.php.net/note/delete/66481/integrated Del: useless -- http://master.php.net/note/delete/66481/useless Del: bad code -- http://master.php.net/note/delete/66481/bad+code Del: spam -- http://master.php.net/note/delete/66481/spam Del: non-english -- http://master.php.net/note/delete/66481/non-english Del: in docs -- http://master.php.net/note/delete/66481/in+docs Del: other reasons-- http://master.php.net/note/delete/66481 Reject -- http://master.php.net/note/reject/66481 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111907) next »