Home  >  Article  >  Backend Development  >  php://memory 怎么用

php://memory 怎么用

WBOY
WBOYOriginal
2016-06-13 10:17:001452browse

php://memory 如何用
我的本意是希望加载控制器文件能更加高效,毕竟读内存要比读磁盘快的多。
我查了一下 include 可能支持 php://memory 这样的协议,但手册上并没有说过这该怎么用,而且我也没google到。
我瞎蒙试着用 php://memory/test 和 php://memory:test ,但都是错的

------解决方案--------------------
没用过啊,进来一起学习.
------解决方案--------------------
我也占位哈 呵呵
------解决方案--------------------
你的需求eAccelerator之类的不是更好?

内存中是很快,我试过memcache里,加载20个文件,eval,平均总耗时比磁盘读取快

有个读取的例子

PHP code
$fp = fopen("php://memory", 'r+');fputs($fp, "hello world!\n");rewind($fp);while(!feof($fp)){    echo fread($fp, 1024);}fclose($fp);<br><font color="#e78608">------解决方案--------------------</font><br>这样试试<br><br>$fp = fopen('php://memory','r+');<br>fputs($fp, 'abcd');<br>rewind($fp);<br>echo fgets($fp);<br><div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn