PHP全局变量教程
Published
2022-12-12
浏览次数 : 304
$_GLOBALS
$_GLOBALS打印出所有的全局变量,当做索引存储在$_GLOBALS里面,
比方说你有全局变量$theme_fields, 那这形式就是 $_GLOBALS【‘theme_fields’】,
相当于 先申明 global $theme_fields , 然后设置$theme_fields.
WP自带的全局变量
1:SIte globals
2:Admin globals
3:Browser detection globals
4:Web server detection globals
5:Version variable globals
Browser Detection globals
is_iphone, is_chrome, is_safari, is_opera, is_macIE,is_edge 等。
global $is_chrome;
if ($is_chrome) {
# code...
echo "You are useing chrome";
}
if ($is_edge) {
# code...
echo "You are using edge";
}
firefox的话 是 $is_gecko
Web server / version detection
if ($is_apache) {
# code...
echo "<h2>You are useing apache</h2>";
} else {
echo "SYSTME has no server";
}
Version
$wp_version, $wp_db_version, $tinymce_version, $mnifest_version, $required_php_version, $required_mysql_version