Soheil
Soheil

Reputation: 5364

Get the filename without extension from a filepath string

How Do I find the name of the page title from $_SERVER['php_self']?

Let's say the $_SERVER shows my page like this: /application/mysite/signup.php.

How can I select the page title signup?

Upvotes: 2

Views: 180

Answers (1)

Leri
Leri

Reputation: 12525

You can use basename:

echo basename($_SERVER['php_self'], '.php');

or pathinfo:

$pathInfo = pathinfo($_SERVER['php_self']);
echo $pathInfo['filename'];

Upvotes: 11

Related Questions