note 95061 added to function.apc-add
| From: | auhoque at gmail dot com | Date: | Fri, 11 Dec 2009 09:24:45 +0000 |
| Subject: | note 95061 added to function.apc-add | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163844@lists.php.net to get a copy of this message | ||
Please note that, the above given example
<?php
$bar = 'BAR';
apc_add('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
$bar = 'NEVER GETS SET';
apc_add('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
?>
Will not display
string(3) "BAR"
string(3) "BAR"
Because you are trying to add different value(or variable) by using same key (named
âfooâ). As per my understanding the output should be
string(3) "BAR"
bool(false)
According to apc_add() specification it is ok. If you want to store value by using same key, your
code should be
<?php
$bar = 'BAR';
apc_add('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
$bar = 'NEVER GETS SET';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
?>
----
Server IP: 69.147.83.197
Probable Submitter: 120.50.18.210
----
Manual Page -- http://www.php.net/manual/en/function.apc-add.php
Edit -- https://master.php.net/note/edit/95061
Del: integrated -- https://master.php.net/note/delete/95061/integrated
Del: useless -- https://master.php.net/note/delete/95061/useless
Del: bad code -- https://master.php.net/note/delete/95061/bad+code
Del: spam -- https://master.php.net/note/delete/95061/spam
Del: non-english -- https://master.php.net/note/delete/95061/non-english
Del: in docs -- https://master.php.net/note/delete/95061/in+docs
Del: other reasons-- https://master.php.net/note/delete/95061
Reject -- https://master.php.net/note/reject/95061
Search -- https://master.php.net/manage/user-notes.php