Results 1 to 5 of 5
  1. #1
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    PHP file name help
    I used to run this at my old web host and it works:

    getenv("SCRIPT_NAME");

    On the new server, it won't return the page that the users is looking at. I get this:

    /cgi-bin/php

    I think the new web host has set up PHP differently that my old one. At the new place, I can actually edit my own php.ini file (inside the cgi-bin) so others on the same sever won't be affected by my changes.

    Does anyone know how I can grab the filename / page (ie. /index.html) that the code is running on?

    TIA!

  2. #2
    Affiliate Marketer Rogi's Avatar
    Join Date
    January 18th, 2005
    Location
    Melbourne
    Posts
    415
    From PHP.Net (available @ http://php.net/reserved.variables)

    $_SERVER["PHP_SELF"]
    The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

    $_SERVER["REQUEST_URI"]
    The URI which was given in order to access this page; for instance, '/index.html'.

  3. #3
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    Fantastic Rogi. Now why couldn't me new web host just tell me that. They both work falwlessy! Thanks!

  4. #4
    Affiliate Marketer Rogi's Avatar
    Join Date
    January 18th, 2005
    Location
    Melbourne
    Posts
    415
    Happy to help. Cheers

  5. #5
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,015
    Quote Originally Posted by Affiliate Ian
    On the new server, it won't return the page that the users is looking at. I get this:

    /cgi-bin/php

    I think the new web host has set up PHP differently that my old one. At the new place, I can actually edit my own php.ini file (inside the cgi-bin) so others on the same sever won't be affected by my changes.
    Unfortunately, it also means you will execute php scripts slower here than there.

    You can run your own php.ini changes just about anywhere:
    PHP Code:
    ini_set("varname""newvalue"); 
    see ini_set()

    See also http://us3.php.net/manual/en/configuration.changes.php

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP question - include(file.php) with variables
    By teezone in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: September 4th, 2009, 04:54 PM
  2. Replies: 0
    Last Post: April 24th, 2009, 09:31 AM
  3. Php Script to Download Web File Not Working
    By Uncle Rico in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: January 19th, 2009, 01:11 PM
  4. Replies: 2
    Last Post: January 1st, 2009, 12:04 AM
  5. How do I insert a PHP script into a .htm file
    By dak142 in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: April 2nd, 2004, 06:24 AM

Posting Permissions

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