当无法访问Web上的某些内容(api,数据库)时,如何停止执行脚本的其余部分并将错误记录在日志文件中?嗯,所以访问者不会看到确切的原因,而是他们会看到我的自定义消息(例如,'一件坏事刚刚发生').我需要采取哪些步骤来安排事情?
根据赋予我的任务,我试图看到php的以下两个函数对图像文件的影响1. imagecreatefromjpeg 2. imagejpeg
我使用html上传文件,然后我的PHP代码如下所示:
<?php
try{
if(!$image=imagecreatefromjpeg('zee1.jpg')){
throw new Exception('Error loading image');
}
// create text color for jpg image
if(!$textColor=imagecolorallocate($image,0,255,0)){
throw new Exception('Error creating text color');
}
// include text string into jpg image
if(!$text=imagestring($image,5,10,90,'This is a sample text
string.',$textColor)){
throw new Exception('Error creating image text');
}
header("Content-type:image/jpeg");
// display image
imagejpeg($image, 'zee1After.jpg');
// free up memory
imagedestroy($image);
}
catch(Exception $e){
echo $e->getMessage();
exit();
}
?>
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我得到以下输出:
致命错误:第3行的C:\ Users\zee\Documents\Flex Builder 3\CLOUD\bin-debug\upload_file.php中允许的内存大小为33554432字节(尝试分配10368字节)
原始图像的大小是:5,136 KB运行php后出现上述错误.
但如果我尝试其他大小的图像:2,752 KB它的工作..
有人可以帮我这个.Zeeshan