Hello,
I have:
$page_file_temp = $_SERVER["PHP_SELF"];
which will output: /templates/somename/index.php
I want to extract from that path only "/templates/somename/"
How can I do it? Thanks!
Hello,
I have:
$page_file_temp = $_SERVER["PHP_SELF"];
which will output: /templates/somename/index.php
I want to extract from that path only "/templates/somename/"
How can I do it? Thanks!
An alternative:
$directory = pathinfo($page_file_temp,PATHINFO_DIRNAME);
Using parse_url will account for GET variables and "fragments" (portion of URL after #) amongst other URL-specific parts.
$url = $_SERVER['PHP_SELF']; // OR $_SERVER['REQUEST_URI']
echo parse_url($url, PHP_URL_PATH);