惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - wangbin

Provider 错误 '80004005' 未指定的错误 的最终解决方法 C#(WinForm)实现软件注册 设置字段默认值sql语句 .net WINFORM 界面怎么做凹凸效果的分割线?就是横线 winform屏蔽Alt+F4组合键以防止用户关闭对话框 游标Cursor 使用小例 (SQLServer) SQL Server 2005 数据类型和.Net数据类型的对应关系 我改行了 PHP $_FILES详解 - wangbin - 博客园 [转载]php-数组操作foreach、each、reset、list .net 随机数 C#混淆 xenocode使用说明 [原创]一个简单的药店用的会员积分管理系统 [原创]xml序列化 [原创]c# as用法 [原创]闲来无事,写了个c#的数据库附加工具,现附上源代码 一个能够在线创建flash网页的站点 [原创]我的cms项目 简洁、标准的对联广告代码
php $GLOBALS 超全局变量的理解
wangbin · 2010-04-18 · via 博客园 - wangbin

全局变量是指可以在程序的任何范围内访问的,比如$_POST, $_GET 等,在函数内部可以访问,在函数外部也可以访问,但普通的函数外定义的变量是不可以在函数内部访问的。比如:

复制内容到剪贴板

代码:

$GLOBALS['testGlobal'] = '123';
$testVar = 'abc';
function showVar()
{
    echo $GLOBALS['testGlobal']; //此行可以显示123,因为这是个全局变量
    echo $testVar; //此行并不能显示abc,因为函数内部无法访问$testVar这个普通变量。
}
showVar(); //显示 123

全局变量并不是指变量可以跨文件访问,跨文件访问PHP是做不到的,要访问另一个文件中定义的变量只能先包含那个文件。