Q:

Remove PHP extension from page naming function

How can I remove the script extension from this function? 
<? php
function curPageName() {
 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}

echo "The current page name is ".curPageName();
? >

For instance, it will echo The current page name is index.php.  How can I remove the .php ? 

A:

try substr()
echo "The current page name is ".substr(curPageName(),0,-4); 

will cut last four char from string and return remain string like:-
echo substr('sdgfjsgdfj.php',0,-4); //returns sdgfjsgdfj 

0 = start of string, -4 = remove string from back limit
substr ( string $string , int $start [, int $length ] )

so if you want remove .php then char length is 4 so need to pass -4 and need result from start so starting from 0 to last strip -4 staring
For more follow manual :- http://php.net/manual/en/function.substr.php

