2017-03-31 87 views
2

我有以下代碼:PHP - 的134217728個字節允許內存大小耗盡

<?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 protected]"; 

    // 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"); 
?> 

因爲我寫的郵件()函數,我得到這個錯誤:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes)

回答

4

隨着猜測它將進入一個無限循環。由於您是命名空間,請更新mail($to, $subject, $message)\mail($to, $subject, $message)並嘗試。在PHP中,函數名稱不區分大小寫。 \mail(...)將調用全局PHP函數。

相關問題