Home >Backend Development >PHP Tutorial >Usage of PHP_SELF and basename_PHP tutorial

Usage of PHP_SELF and basename_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:30:47818browse

$php_self = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];

if ('/' == substr($php_self, -1)){

    $php_self .= 'index.php';

}

define('PHP_SELF', $php_self);

If

echo basename(PHP_SELF)

is displayed as: index.php

If

echo basename(PHP_SELF,'.php')

Displayed as: index

Articles you may be interested in

  • php finds whether a value exists in an array (in_array(), array_search(), array_key_exists() )
  • phpMyAdmin Cannot start session without errors error solution
  • php prompts Maximum execution time of 30 seconds exceeded... Error solution
  • PHP reports Fatal error Allowed memory size of...How to solve the out of memory error
  • Detailed explanation of PHP string escape functions (addslashes, stripslashes)
  • php prompt PHP Warning: date(): It is not safe to Rely on the... Error solution
  • The usage and difference of using break, continue, goto, return, exit to break out of multiple loops in PHP
  • php string replacement function str_replace Faster than preg_replace

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764199.htmlTechArticle$php_self = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER ['SCRIPT_NAME'];if ('/' == substr($php_self, -1)){ $php_self .= 'index.php';}define('PHP_SELF', $php_self);...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn