Dave's Brain

Browse - programming tips - php name of this script

Date: 2009may22
Language: php

Q.  How can I find the name of the current script?

A.  Use the function below:

// Helper function
function get_server($var)
{
        return isset($_SERVER[$var]) ? $_SERVER[$var] : '';
}

function get_self()
{
        return basename(get_server('PHP_SELF'));
}

function example_use()
{
	if (get_self() == 'index.php')
	{
		print 'Welcome';
	}
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: