PHP代码:
$hello = "你好" ;
function aaa ()
{
echo $hello;
}
aaa() ;JS代码:
var hello = "你好" ;
function aaa ()
{
alert(hello);
}
aaa() ;为什么JS代码能运行,而PHP代码不能运行?
$hello = "你好" ;
function aaa ()
{
echo $hello;
}
aaa() ;JS代码:
var hello = "你好" ;
function aaa ()
{
alert(hello);
}
aaa() ;为什么JS代码能运行,而PHP代码不能运行?
$hello = "你好" ;
function aaa ()
{
global $hello;
echo $hello;
}
aaa() ;否则默认是局部变量。
但从结构化编程的角度看,php 进了一大步