...

View Full Version : Resolved Php self



Joseph Witchard
02-19-2010, 04: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?

_Aerospace_Eng_
02-19-2010, 04:29 AM
Why don't you comment out the mail part and echo the $script variable and test it yourself?

bdl
02-19-2010, 04:29 AM
PHP superglobals (http://us2.php.net/manual/en/language.variables.superglobals.php) : $_SERVER (http://us2.php.net/manual/en/reserved.variables.server.php)



The filename of the currently executing script, relative to the document root.

Joseph Witchard
02-19-2010, 06:30 AM
Why don't you comment out the mail part and echo the $script variable and test it yourself?

I'm sorry.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum