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);
?>
shm_put_var
(PHP 4, PHP 5)
shm_put_var — Inserta o actualiza una variable en la memoria compartida
Descripción
shm_put_var() inserta o actualiza la variable con la clave_variable entregada.
Se emitirán advertencias (del nivel E_WARNING) si identificador_shm no es un índice de memoria compartida SysV, o si no existe suficiente memoria compartida disponible para completar su solicitud.
Lista de parámetros
- identificador_shm
-
- clave_variable
-
- variable
-
La variable. Todos los tipos de variables son soportados.
Valores retornados
Devuelve TRUE si todo se llevó a cabo correctamente, FALSE en caso de fallo.
shm_put_var
jasonrlester at yahoo dot com
25-Apr-2008 07:51
25-Apr-2008 07:51
troy
06-Mar-2008 03:02
06-Mar-2008 03: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
30-Sep-2004 11:53
30-Sep-2004 11: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.
