how to display filename in php?

Discussion in 'Site & Server Administration' started by ashiezai, Jun 1, 2005.

  1. #1
    let's say my filename is like
    http://www.xxx.com/abc.php

    Is the a way to display the filename on the page and without the file type?

    Like i'll be displaying the text like:
    Buy abc online

    I've searched everywhere but no luck .. i've several hundreds on page to be done so i dont think i can handcode them one by one ..
     
    ashiezai, Jun 1, 2005 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    $PHP_SELF and trim the extension off with substr()?
     
    noppid, Jun 1, 2005 IP
  3. ashiezai

    ashiezai Peon

    Messages:
    927
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry im a php noob. I know very very little of php ..
    Can you show me how to do that?

    with echo?
     
    ashiezai, Jun 1, 2005 IP
  4. ashiezai

    ashiezai Peon

    Messages:
    927
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've finally got it :

    <?php $rest = substr(getenv('SCRIPT_NAME'), 1, -4);
    echo $rest;?>

    i feel good as im a php noob. I combined a few examples out there :)
     
    ashiezai, Jun 1, 2005 IP