我有以下代码:
<?php
namespace Debug;
function Alert($msg){
$temp = "<script>alert('".$msg."')</script>";
echo $temp;
}
function Log($msg){
$temp = "<script>console.log('".$msg."')</script>";
echo $temp;
}
function Mail($message, $subject){
$to = "email@email.com";
// Sending email
if(mail($to, $subject, $message)){
echo 'Your feedback has been sent successfully.';
} else{
echo 'Unable to send feedback. Please try again.';
}
}
?>
不同的档案:
<?php
$name = $_POST['feedback_name'];
$email = $_POST['feedback_email'];
$msg = $_POST['feedback_message'];
echo $name;
echo $email;
echo $msg;
include 'WebLib.php';
Debug\Mail($msg, "Feedback");
?>
由于我编写了Mail()函数,我收到此错误:
致命错误:允许的内存大小为134217728字节耗尽(尝试分配65488字节)
答案 0 :(得分:5)
随着猜测,它将进入一个无限循环。将mail($to, $subject, $message)
更新为\mail($to, $subject, $message)
并尝试,因为您是命名空间。在PHP中,函数名称不区分大小写。 \mail(...)
将调用全局PHP函数。