概述
静态变量虽然在函数结束时值不丢失,但其作用域只在本函数中,在函数之外仍然是无效的
如:function mytest(){
static $mystr;
$mystr.="哈";
echo $mystr."
";
}
echo mytest();//哈
echo mytest();//哈哈
echo mytest();//哈哈哈
$request=null;
is_null($request) && $request = "我是request"; <=等同于=> if(is_null($request)) $request = "我是request";
var_dump($request);
$script_name = basename($_SERVER['SCRIPT_FILENAME']);
if (basename($_SERVER['SCRIPT_NAME']) === $script_name) {
$url = $_SERVER['SCRIPT_NAME'];
echo 1;
} elseif (basename($_SERVER['PHP_SELF']) === $script_name) {
$url = $_SERVER['PHP_SELF'];
echo 2;
} elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name) {
$url = $_SERVER['ORIG_SCRIPT_NAME'];
echo 3;
} elseif (($pos = strpos($_SERVER['PHP_SELF'], '/' . $script_name)) !== false) {
$url = substr($_SERVER['SCRIPT_NAME'], 0, $pos) . '/' . $script_name;
echo 4;
} elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) {
$url = str_replace('\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
echo 5;
}
echo basename($_SERVER['SCRIPT_FILENAME'])."
";
echo basename($_SERVER['SCRIPT_NAME'])."
";
echo basename($_SERVER['PHP_SELF'])."
";
echo basename($_SERVER['ORIG_SCRIPT_NAME'])."
";
echo basename($_SERVER['DOCUMENT_ROOT'])."
";
$path_parts=pathinfo('/www/htdocs/inc/lib.inc.php');
echo$path_parts['dirname'],"n";
echo$path_parts['basename'],"n";
echo$path_parts['extension'],"n";
echo$path_parts['filename'],"n";// since PHP 5.2.0/www/htdocs/inc
lib.inc.php
php
lib.inc
public functionisSsl()
{$server=array_merge($_SERVER,$this->server);if(isset($server['HTTPS']) && ('1'==$server['HTTPS'] ||'on'==strtolower($server['HTTPS']))) {return true;
}elseif(isset($server['REQUEST_SCHEME']) &&'https'==$server['REQUEST_SCHEME']) {return true;
}elseif(isset($server['SERVER_PORT']) && ('443'==$server['SERVER_PORT'])) {return true;
}elseif(isset($server['HTTP_X_FORWARDED_PROTO']) &&'https'==$server['HTTP_X_FORWARDED_PROTO']) {return true;
}elseif(Config::get('https_agent_name') &&isset($server[Config::get('https_agent_name')])) {return true;
}return false;
}
最后
以上就是勤劳哈密瓜为你收集整理的php 解析 执行,php解析执行基础代码的全部内容,希望文章能够帮你解决php 解析 执行,php解析执行基础代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复