Joseph Witchard
02-19-2010, 03:25 AM
Consider this file:
// error_check.php
function error_check($email)
{
$subject = 'ERROR!';
$script = $_SERVER['PHP_SELF'];
$message = "There was an error on example.com$script";
mail($email, $subject, $message);
}
Now consider this file:
// do_something.php
require('error_check.php');
$to = 'someone@example.com';
error_check($to);
So, since error_check.php is included via require(), what will the PHP_SELF variable be? Since it's included in the second file, would it have the value /do_something.php, or since it is declared in the first file, will it have the value of /error_check.php?
// error_check.php
function error_check($email)
{
$subject = 'ERROR!';
$script = $_SERVER['PHP_SELF'];
$message = "There was an error on example.com$script";
mail($email, $subject, $message);
}
Now consider this file:
// do_something.php
require('error_check.php');
$to = 'someone@example.com';
error_check($to);
So, since error_check.php is included via require(), what will the PHP_SELF variable be? Since it's included in the second file, would it have the value /do_something.php, or since it is declared in the first file, will it have the value of /error_check.php?