note 110175 added to function.apc-fetch

From: Date: Wed, 26 Sep 2012 18:30:27 +0000
Subject: note 110175 added to function.apc-fetch
Groups: php.notes 
Request: Send a blank email to php-notes+get-191034@lists.php.net to get a copy of this message
Make sure to check the return value using a strict comparison if you want to know whether apc_fetch failed unless you want anything stored that can be evaluated to false to report an error aswell. E.g. the following is bad: <?php $result = apc_fetch("key"); if(!$result) { //handle error } ?> If key is an empty array or the value 0, it will naturally evaluate to false and trigger the error. To avoid this, do instead: <?php $result = apc_fetch("key"); if($result === false) { //handle error } ?> Side note: avoid storing booleans in APC :) ---- Server IP: 69.147.83.199 Probable Submitter: 91.89.29.47 ---- Manual Page -- http://www.php.net/manual/en/function.apc-fetch.php Edit -- https://master.php.net/note/edit/110175 Del: integrated -- https://master.php.net/note/delete/110175/integrated Del: useless -- https://master.php.net/note/delete/110175/useless Del: bad code -- https://master.php.net/note/delete/110175/bad+code Del: spam -- https://master.php.net/note/delete/110175/spam Del: non-english -- https://master.php.net/note/delete/110175/non-english Del: in docs -- https://master.php.net/note/delete/110175/in+docs Del: other reasons-- https://master.php.net/note/delete/110175 Reject -- https://master.php.net/note/reject/110175 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191034) next »