问题描述
我尝试添加 ini_set('memory_limit'),当我尝试调用mail()函数时, '64m')
到我的index.php文件 - 其中包含()的所有其他文件 - 但它没有解决它。
然后,我尝试将php.ini文件添加到根目录(index.php所在的位置),内容是
memory_limit = 64M
,然后给我 PDO没有找到类别错误。所以我添加到php.ini文件的PDO扩展,现在所有错误都消失了。 但是,代码仍然失败。 phpinfo()显示内存限制已经增加到64M,但是我的mail()函数正在杀死页面的执行。
我该如何解决? :/
邮件功能
private static function emailPassword(SafeString $ email,$ password)
{
$ subject ='注册';
$ message ='您的密码是:'。 $密码。 \\\
;
$ headers ='From:[email protected]'。 \r\\\
;
$ headers。='回覆:[email protected]'。 \r\\\
;
$ message = str_replace(\\\
。,\\\
..,$ message);
if(!mail($ email-> unsafeRaw(),$ subject,$ message,$ headers))
{
throw new Exception('Failed');
}
}
33 554 432字节)+(41 007 872字节)= 71.1081543兆字节
将你的memory_limit设置为96M,并称之为一天!
I'm getting this error when I try to call the mail() function.
I tried adding ini_set('memory_limit', '64m')
to my index.php file - Which include()'s all other files into that - But it didn't fix it.
I then tried adding a php.ini file into the root directory (where index.php resides) with the contents memory_limit = 64M
which then gave me PDO Class not found errors. So I added in the PDO extensions to the php.ini file and now all errors are gone.
However, the code still fails. phpinfo() shows the memory limit has been increased to 64M but my mail() function is killing the execution of the page.
How can I fix this? :/
Mail function
private static function emailPassword(SafeString $email, $password)
{
$subject = 'Registration';
$message = 'Your password is: ' . $password . "\n";
$headers = 'From: [email protected]' . "\r\n";
$headers .= 'Reply-to: [email protected]' . "\r\n";
$message = str_replace("\n.", "\n..", $message);
if (!mail($email->unsafeRaw(), $subject, $message, $headers))
{
throw new Exception('Failed');
}
}
(33 554 432 bytes) + (41 007 872 bytes) = 71.1081543 megabytes
Set your memory_limit to 96M and call it a day!
这篇关于PHP致命错误:允许的内存大小为33554432字节耗尽(尝试分配41007872字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!