note 48828 added to function.shmop-read

From: Date: Fri, 07 Jan 2005 22:19:10 +0000
Subject: note 48828 added to function.shmop-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-82937@lists.php.net to get a copy of this message
shmop_read() reads and returns the whole memory segment's data. This is not useful if you're just working with strings. If you need to read a string from shared memory, call str_from_mem() on the result of shmop_read(). Similarly when writing strings to memory (instead of binary data), null terminate your strings with str_to_nts() before passing the value on to shmop_write(). function str_to_nts($value) { return "$value\0"; } function str_from_mem(&$value) { $i = strpos($value, "\0"); if ($i === false) { return $value; } $result = substr($value, 0, $i); return $result; } ---- Manual Page -- http://www.php.net/manual/en/function.shmop-read.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48828 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48828&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48828&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48828&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48828&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48828&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48828&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48828&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82937) next »