上一篇:将.wmv等格式的文件转换为.flv格式
下一篇:高考雷句大汇总,笑死你不偿命!
探究PHP编程管理内存
米娅 2010年6月25日 14:52:40

楼主按:我也是在学习

1,ob_start()这个命令就是在发送文件头之前页面内容被缓存在内存中。

2,一个看着不错的开源软件:eAccelerator

摘录一段:

eAccelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.

eAccelerator was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelerator code is still based on his work.

翻译和解释如下: eAccelerator是免费开源PHP加速和优化器。它通过在内存中缓存PHP代码来加速它的执行速度。 MMCache原作者是Dmitry Stogov,后被Zend挖走。很多Eaccelerator代码是基于MMCache。


3. Shared Memory Functions
2楼 2010年6月25日 16:24:59 米娅

英文来源: php.net

Table of Contents

  • shmop_close — Close shared memory block 关闭共享内存块
  • shmop_delete — Delete shared memory block 删除共享内存块
  • shmop_open — Create or open shared memory block  创建共享内存块
  • shmop_read — Read data from shared memory block  读取共享内存块的数据
  • shmop_size — Get size of shared memory block 获得共享内存块的大小
  • shmop_write — Write data into shared memory block 写数据到共享内存块 

这里是例子 

如果出现这个错误: Fatal error: Call to undefined function shmop_open() in...
到php.ini把 extension=php_shmop.dll 前的“;”去掉,重新编译,使生效。

待续 


3楼 2010年6月27日 14:43:57 米娅

按:不知道怎么Windows下怎么编译php,就重启了一下,显示如下。网站空间不支持shmop,所以,目前还用不到这个,放这里做个记号。

SHM Block Size: 100 has been created. The data inside shared memory was: my shared memory block

附上述的例子代码:

< ?php
   
// Create 100 byte shared memory block with system id of 0xff3
$shm_id shmop_open(0xff3"c"0644100
);
if (!
$shm_id
) {
    echo 
"Couldn't create shared memory segment\n"
;
}

// Get shared memory block's size
$shm_size shmop_size($shm_id
);
echo 
"SHM Block Size: " $shm_size " has been created.\n"
;

// Lets write a test string into shared memory
$shm_bytes_written shmop_write($shm_id"my shared memory block"0
);
if (
$shm_bytes_written != strlen("my shared memory block"
)) {
    echo 
"Couldn't write the entire length of data\n"
;
}

// Now lets read the string back
$my_string shmop_read($shm_id0$shm_size
);
if (!
$my_string
) {
    echo 
"Couldn't read from shared memory block\n"
;
}
echo 
"The data inside shared memory was: " $my_string "\n"
;

//Now lets delete the block and close the shared memory segment
if (!shmop_delete($shm_id
)) {
    echo 
"Couldn't mark shared memory block for deletion."
;
}
shmop_close($shm_id
);
   
? > 
 

第1页 共1页
相关链接