[PHP]Maximum execution time of 30 seconds exceeded
原因:在使用PHP渲染页面页面的时候,如果程序处理的时间特别久,超过配置文件(php.ini)设置的超时时间。例如:导入大量数据到数据库中;请求资源时间过长……
解决方法:
1、直接修改配置文件(php.ini)[超时]
默认的最大执行时间是30s,可根据自己的需求做修改
如果是0,即永不过期
max_execution_time = 30;
2、间接修改配置信息[超时]
在php执行文件中加入如下代码:
set_time_limit(0);
3、刷新输出缓冲[内存超限]
1)在循环当中做延迟执行:加入函数sleep(time)
2)输出缓冲:同时使用ob_flush()和flush()函数将数据发送到浏览器
<?phpfor ($i=0; $i < 10000; $i++) {echo "hello ".printf('%05s',$i).'<br/>';ob_flush();flush();}
[PHPExcel]Uncaught exception ‘PHPExcel_Exception’ with message ‘Maximum 31 characters allowed in sheet title’
解决方法:
找到文件PHPExcel/Worksheet.php
private static function _checkSheetTitle($pValue){// Some of the printable ASCII characters are invalid: * : / \ ? [ ]if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {throw new PHPExcel_Exception('Invalid character found in sheet title');}// Maximum 31 characters allowed for sheet titleif (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {throw new PHPExcel_Exception('Maximum 31 characters allowed in sheet title.');}return $pValue;}
在其中加上
$pValue = substr($pValue, 0, 31);
[PHP]mkdir() No such file or directory
描述:当直接使用mkdir($filepath)时,如果本身路径身,而中间路径又不存在时可能会报此种错误
解决方法:
if(!is_dir($excel_path)) mkdir($excel_path,0777,true);
