解决PHP内存溢出的问题
Allowed memory size of 33554432 bytes exhausted (tried to allocate 4554 bytes)
有时候我们在运行php程序的时候会发现 Fatal Error: Out of memory 这样的提示。 这有可能是程序中用到了大量了变量和对象,导致分配的内存不够用。我就遇到这样一个错误怎么改也改不了,后来上网查了一些资料,可是修改了php.ini文件里的memory_limit参数,可是无论我怎么改还是有这个错误提示,特别郁闷!后来我实在没有办法了,就在QQ群里面求助,有人告诉我在我的程序代码中加入“init_set("memory_limit", "128M");”这行代码就可以了,于是我试了一下,还真的行了。现在我把自己解决这个问题的两种办法分享给大家,希望能帮到和我一样遇到类似问题的人们。
方法一:我们可以在php.ini文件中把memory_limit参数默认的128M修改为256M或者更大:
memory_limit = 128M
方法二:如果是虚拟主机,我们可以在程序需要用到大内存的地方添加:
init_set("memory_limit", "128M");
这些可以在硬件环境方面解决我们的问题,不过最好的方法还是严格控制程序中内存的损耗。及时unset一些大而不用的变量或对象。
相关文档:
原帖地址:http://www.phpma.com/english/20071215/640.html
Description
array explode
( string separator, string string [, int limit])phpma.com
Returns an array of strings, each of which is a substring of string
formed by splitting it on boundaries formed by the string separator
. If limit
is ......
import flash.net.FileFilter;
import flash.net.FileReferenceList;
import fl.controls.Button;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.HTTPStatusEvent;
import flash.display.Loader;
import flash.net.URLRequest;
var ......
/*
用PHP的DOM控件来创建XML输出
设置输出内容的类型为xml
*/
header('Content-Type: text/xml;');
//创建新的xml文件
$dom = new DOMDocument('1.0', 'utf-8');
//建立<response>元素
$response = $dom->createElement('response');
$dom->appendChild($response);
//建立<books>元素并将其作 ......
昨天回家来,今天粗略看了一下《大道PHP》,书很细,C++的也是大概看了一下,总之,收获不大,也许第一天的缘故吧。
必须排除干扰,死心蹋地的学习了,高效的完成寒假的任务,PHP和C++基本功,VC++,MFC,可能的话,分析一下Dizcuss也是不错的,养成良好的编程风格和习惯。下半年, ......
php特殊字符过滤
1、过滤标签(HTML):strip_tags()
例如:
<?php
$text = '<?php ?><p>Test paragraph.</p><!-- Comment -
-> <a href=http://topic.csdn.net/u/20090311/09/"#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// 允许使用<p>和< ......