(小白)尝试用PHP梳理 借阅系统源码001 20200929
相关工具
phpstudy:8.1.0.5
navicat:11.2.7
HBuilder: 7.6.5.201612301621
历程
- 了解 define(‘PHP_FILE’,
S
E
R
V
E
R
[
′
S
C
R
I
P
T
N
A
M
E
′
]
)
;
定
义
一
个
P
H
P
F
I
L
E
的
常
量
,
值
为
_SERVER['SCRIPT_NAME']); 定义一个_PHP_FILE_的常量,值为
SERVER[′SCRIPTNAME′]);定义一个PHPFILE的常量,值为_SERVER[‘SCRIPT_NAME’]
最好在以下文件中找到_server,.但并没有SCRIPT_NAME
WWW\bookstore\Think\Library\Vendor\phpRPC\phprpc_client.php
$this->_server['scheme'] = $urlparts['scheme'];
$this->_server['host'] = $urlparts['host'];
$this->_server['port'] = $urlparts['port'];
$this->_server['path'] = $urlparts['path'];
$this->_server['user'] = $urlparts['user'];
$this->_server['pass'] = $urlparts['pass'];
度娘说,这是超全局变量
https://www.cnblogs.com/zhao-/p/10994615.html
$_SERVER[“SCRIPT_NAME”] 当前脚本的路径。这在页面需要指向自己时非常有用。
define(‘PHP_FILE’,$_SERVER[‘SCRIPT_NAME’]);
也就是把当前路径定义给了常量’PHP_FILE’
- install.lock
这是一个安装锁定文件
https://blog.csdn.net/ccfxue/article/details/71108293
在这里插入代码片
if(!file_exists("install.lock")){
if(!preg_match("/install/i", $_SERVER['PATH_INFO'])){
$install=$_SERVER['SCRIPT_NAME'].'/Install';
header("Location:$install");
exit();
}
}
意思是:
当install.lock不存在的时候,执行preg_match
- preg_match
preg_match — 执行匹配正则表达式
https://www.php.net/manual/zh/function.preg-match.php
preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] ) : int
搜索subject与pattern给定的正则表达式的一个匹配.
_SERVER[‘PATH_INFO’]在之前的页面里没有,度娘给的答案:
https://www.cnblogs.com/xiaochaohuashengmi/archive/2011/09/13/2175071.html
相当于php下面的html地址