how to echo pagename from url onto webpage

Discussion in 'PHP' started by aj22, Jul 3, 2007.

  1. #1
    how can i echo the name of page (e.g. www.abcd.com/something.php) into the text of my website? for example, using that url i would want to be able to echo 'something' (without the file extension). is that possible?
     
    aj22, Jul 3, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    
    $a = explode(".",basename($_SERVER['PHP_SELF'])); echo $a[0];
    
    -or-
    
    echo basename(substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],".")));
    
    PHP:
     
    ansi, Jul 3, 2007 IP