note 91592 deleted from function.shm-get-var by danbrown
| From: | danbrown@php.net | Date: | Thu, 18 Jun 2009 12:57:50 +0000 |
| Subject: | note 91592 deleted from function.shm-get-var by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157057@lists.php.net to get a copy of this message | ||
Note Submitter: benjamin at josefus dot net
----
Don't just suppress Warnings! Solve Problems!
The Reference says:
"mixed shm_get_var ( resource $shm_identifier , int $variable_key ) "
So don't let neither an array nor a string or something else to be the 2nd Parameter! An
Integer (a possibly quite long one) is expected!
WRONG
This causes a Warning "shm_put_var() expects parameter 2 to be long, string given" and
shm_put_var() failed with returning FALSE.
<?php
// ...
$a = "any kind of data";
shm_put_var($shm_id, $a, $a);
?>
RIGHT
Use a (long) Integer to be Key for Shared Variable
<?php
// ...
$a = "any kind of data";
shm_put_var($shm_id, 12345, $a);
?>