Home > php教程 > php手册 > PHP_SELF和basename的用法

PHP_SELF和basename的用法

WBOY
Release: 2016-06-13 09:36:06
Original
1590 people have browsed it

$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);
Copy after login

如果

echo basename(PHP_SELF)
Copy after login

显示为:index.php

如果

echo basename(PHP_SELF,'.php')
Copy after login

显示为:index

您可能感兴趣的文章

  • php在数组中查找某个值是否存在(in_array(),array_search(),array_key_exists())
  • phpMyAdmin Cannot start session without errors错误解决办法
  • php提示Maximum execution time of 30 seconds exceeded...错误的解决办法
  • PHP报Fatal error Allowed memory size of...内存不足的错误应该如何解决
  • PHP 字符串转义函数(addslashes,stripslashes)详解
  • php提示PHP Warning: date(): It is not safe to rely on the......错误的解决办法
  • PHP中跳出多重循环使用break,continue,goto,return,exit的用法和区别
  • php字符串替换函数str_replace速度比preg_replace快
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template