Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: shm_put_var - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

shm_remove_var" width="11" height="7"/> <shm_get_var
Last updated: Fri, 22 Aug 2008

view this page in

shm_put_var

(PHP 4, PHP 5)

shm_put_var共有メモリの変数を挿入または更新する

説明

bool shm_put_var ( int $shm_identifier , int $variable_key , mixed $variable )

shm_put_var() は、 指定した variable_key を有する 変数 variable の挿入または更新を行います。

shm_identifier が有効な SysV 共有メモリではない場合や リクエストを処理するために充分な共有メモリが残っていない場合は (E_WARNING レベルの) 警告を発生させます。

パラメータ

shm_identifier

shm_attach() が返す共有メモリリソースハンドル。

variable_key

変数のキー。

variable

変数。全ての 変数型をサポートします。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。



shm_remove_var" width="11" height="7"/> <shm_get_var
Last updated: Fri, 22 Aug 2008
 
add a note add a note User Contributed Notes
shm_put_var
jasonrlester at yahoo dot com
26-Apr-2008 04:51
sadly troy is right

the following script will return:

resource(5) of type (stream)
int(0)

<?php

define
("FOPEN_RESOURCE", 1);
define("FOPEN_FILEPATH", "/path/to/file");

$fopen_resource = fopen(FOPEN_FILEPATH, "w");

var_dump($fopen_resource);

$shm_id = shm_attach(1);
if (
$shm_id === false)
{
    echo
"Fail to attach shared memory.\n";
}

if (!
shm_put_var($shm_id, FOPEN_RESOURCE, $fopen_resource))
{
    echo
"Failed to put var 1 in shared memory $shm_id.\n";
}

$sm_fopen_resource = shm_get_var($shm_id, FOPEN_RESOURCE);
if (
$sm_fopen_resource === false)
{
    echo
"Failed to retreive fopen_resource from Shared memory\r\n";
}

var_dump($sm_fopen_resource);

if(
$shm_id) shm_remove($shm_id);
if(
$fopen_resource) fclose($fopen_resource);

?>
troy
07-Mar-2008 12:02
This isn't entirely accurate. Not all variable types are supported, you can't put a resource variable into shared memory.

When you try to take it out, it will be a zero.
tomlove at gmail dot com
01-Oct-2004 08:53
Use as few variable_keys as you can. With large arrays of data, rather make the array multi-dimensional and store under one variable_key than use variable_key as your index. The benefit is especially noticeable when repeated fetching from the end of the array is necessary and updates are less frequent.

shm_remove_var" width="11" height="7"/> <shm_get_var
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites