Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Php self

  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    Php self

    Consider this file:

    PHP Code:
    // 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:
    PHP Code:
    // 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?
    Last edited by Joseph Witchard; 02-19-2010 at 06:30 AM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Why don't you comment out the mail part and echo the $script variable and test it yourself?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    Joseph Witchard (02-19-2010)

  • #3
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    PHP superglobals : $_SERVER

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

  • Users who have thanked bdl for this post:

    Joseph Witchard (02-19-2010)

  • #4
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Why don't you comment out the mail part and echo the $script variable and test it yourself?
    I'm sorry.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •