Get the name of the current file with php
If you have a website written in php and you want to get the name of the current page, it is actually very easy.
basename(preg_replace('/\.php$/', , __FILE__))
gives you the name of the current file including .php and the full path.
(preg_replace('/\.php$/', , __FILE__)
which replaces the .php with nothing.
<meta name="keywords" content="<?php echo basename(preg_replace('/\.php$/', , __FILE__)) ?>" />
Was this article helpful? Then please donate to keep The IT Community alive...
If you found this article helpful please share it, comment and help others by writing your own article.
Translate this page:
Articles found in the same category: