Remove PHP extension from page naming function

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

Leave a Comment