gosh i've not posted in this newbie section for ages.. but i feel like a noob asking this.. so here goes..

hehe

i need my script to automatically detect it's own filename.. and also url.. i've dug in the manual.. couldnt find it.. i thought it'd be in the FILESYSTEM functions. but cant find it..

anyone care to point me to the right direction?

thanks and sorry for me stupeed question..i just cant find it.

    thanks.. i should have made my question clearer.. that answers my URL problem.. but i was kinda hoping/needing a function that tell's a script it's own FILENAME

    path with filename is cool and i can parse it no problem to get just the filename. but why parse it if there's a php function for this specific thing? or is there? 🙂

      thanks but i think i'll will still need PARSING.. i just need the FILENAME without the paths..

      I've already been through the php predefined variables section before. these are the only functions that seem to output similar to what i need.. but not exactly..

      <?
      echo $SERVER['SCRIPT_NAME'] . "<br>";
      echo $
      SERVER['SCRIPT_FILENAME'] . "<br>";
      echo $_SERVER['PHP_SELF '] . "<br>";
      ?>

      will woutput:

      /projects/index.php
      d:/teaconcepts/projects/index.php
      /projects/index.php

        also, if you guys can add to this request... need a function that tells a script the current directory it's in. lol

          ah GOT IT!

          $myFreakingName=basename($_SERVER['SCRIPT_NAME']);

          returns only the FILENAME. 🙂 ..had to use 2 functions though. 🙁

            here's an even better one:

            <?php
            $path_parts = pathinfo($_SERVER['SCRIPT_NAME']);

            echo $path_parts['dirname'], "\n";
            echo $path_parts['basename'], "\n";
            echo $path_parts['extension'], "\n";
            ?>

            cool. 🙂 gives me the dir, and the name..

              Write a Reply...