2

I have the following code:

<?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.';
   }
}

?>

Different file:

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

Since I wrote the Mail() function i get this error:

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

float
  • 371
  • 1
  • 6
  • 16

1 Answers1

5

With the guess it is going into an infinite loop. Update mail($to, $subject, $message) to \mail($to, $subject, $message) and try, since you are namespacing. In PHP function names are case insensitive. \mail(...) will call the global PHP function.

Saumini Navaratnam
  • 8,439
  • 3
  • 42
  • 70