<?php
class VariableStream
{
function stream_open($path, $mode, $options, &$opened_path)
{
return true;
}
function stream_read($count)
{
return "x";
}
function stream_write($data)
{
return strlen($data);
}
function stream_tell()
{
return 0;
}
function stream_eof()
{
return true;
}
function stream_seek($offset, $whence)
{
return false;
}
function stream_metadata($path, $option, $var)
{
return true;
}
}
stream_wrapper_register("var", "VariableStream") or die("Failed to register protocol");
chmod("var://myvar", 0777);
/*
$myvar = "";
$fp = fopen("var://myvar", "r+");
fwrite($fp, "line1\n");
fwrite($fp, "line2\n");
fwrite($fp, "line3\n");
rewind($fp);
while (!feof($fp)) {
echo fgets($fp);
}
fclose($fp);
var_dump($myvar);
*/
preferences:
46.17 ms | 402 KiB | 5 Q