문제

This is regarding the PHP global variables. Does it mean the global variables are simply assigned values through the HTTP request(ie: Varaibles where pre-existing but without values), or that the variables are "instantiated" and assigned values(ie: variable where not pre-existing in script)? I am yet to see any text which explains.

도움이 되었습니까?

해결책

PHP's register_globals will create the appropriate global variables and assign values to them. Note that it's probably a really bad idea to use register_globals, since it poses a security risk. It's better to use the superglobal arrays $_POST, $_GET and $_COOKIE.

다른 팁

registering globals simply means the process of registering various request variables as globally available. However, "register" in this case differs fundamentally from "assign" or "set" because the globals are inherently linked to their superglobal key counterparts (or "registered" as an alias), perhaps best summarized by this snippet of code:

// register_globals is on
$_POST["username"] === $username; // true

$username = "foo";
$_POST["username"] === $username; // *still* true

$_POST["username"] = "bar";
$_POST["username"] === $username; // *still* true

That is, changing one will change the corresponding superglobal key. Of course, this behavior should not be relied upon — if you're using register_globals in the first place, you're doing something wrong.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top