Programming Tips - How can I find the name of the current 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'; } }