|
发表于 2006-1-19 16:12:17
|
显示全部楼层
quicksand打破沙锅问到底 ^_^
看看PHP手册的相关信息:
An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope.
将一个相关性的数组通过HTTP POST方法传递当前的脚本。在任意程序段内都属于全局变量。
那么$_POST[action]和$_POST['action']都表示$_POST数组里key值为action对应的值
在看看Array的相关概念:
[code:1]
array( [key =>] value
, ...
)
// key may be an integer or string
// value may be any value 是的,key值可以使整型或字符串
[/code:1]
Why is $foo[bar] wrong?为什么它错了呢?
You should always use quotes around a string literal array index. For example, use $foo['bar'] and not $foo[bar]. But why is $foo[bar] wrong? You might have seen the following syntax in old scripts:
通常都会在数组索引处加上"" 。比如,使用$foo['bar']而不是$foo[bar]。但是为什么$foo[bar]错了呢?你可能在老代码中看到过:
[code:1]
<?php
$foo[bar] = 'enemy';
echo $foo[bar];
// etc
?>
[/code:1]
This is wrong, but it works. Then, why is it wrong? The reason is that this code has an undefined constant (bar) rather than a string ('bar' - notice the quotes), and PHP may in future define constants which, unfortunately for your code, have the same name. It works because PHP automatically converts a bare string (an unquoted string which does not correspond to any known symbol) into a string which contains the bare string. For instance, if there is no defined constant named bar, then PHP will substitute in the string 'bar' and use that.
这是错的,但是它能显示些东东。那么,为什么它错了?因为这个代码是一个未定义的常量(bar)而不是一个字符串('bar'注意那个''),而PHP将来会定义一些常量,而不幸的是在你的代码中使用了同样的名称。后面的不用翻译了...
看看PHP手册的相关内容
[code:1]
$variable = isset($_POST['variable']) ? $_POST['variable'] : $_GET['variable'];
[/code:1]
同样也是标准的获得URL中参数的办法 |
|