Home >Backend Development >PHP Tutorial >php 获取全局变量的代码_php技巧

php 获取全局变量的代码_php技巧

WBOY
WBOYOriginal
2016-05-17 09:19:56929browse
复制代码 代码如下:

function cleanGlobal($global_array, $arg, $specialchars = true, $default = null) {
        if(key_exists($arg, $global_array) && $global_array[$arg] != null && $global_array[$arg] != "") {
                if($specialchars) {
                        return htmlspecialchars($global_array[$arg]);
                } else {
                        return $global_array[$arg];
                }
        } else {
                return $default;
        }
}
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