, . , – PHP. , , , . , , .
, . . PHP , (include) (require).
. , , ? PHP .
"global"
PHP? "global". , (, global «»).
, . - , .
? , . , . PHP. . , , : global a.
, , . – , . , , . . , , .
PHP ? , . $GLOBALS.
. – . . , . . : $GLOBALS[''] .
/
- , . PHP .
. , , «», . ? - , : global «». , , ? , . «» :
- global $HTTP_POST_VARS;
- echo $HTTP_POST_VARS['name'].
? , PHP . , .
, PHP . - ? , global. .
4.2.0 register_globals . , . . , PHP- . .
, register_globals , , , , HTML-. .
php ? , , . , . – . , , .
/ , , PHP . , , , .
, , :
if (authenticate_user()) {
$authorize = true;
}
if ($authorize) {
include "/highly/sensitive/data.php";
}
. , , , - . , ( , ) .
, , . , .
, . , :
if (isset($_SESSION['username'])) {
echo " <b>{$_SESSION['username']}</b>";
} else {
echo " <b>Guest</b><br />";
echo ", !";
}
. – . , . PHP , : , , , . , . .
, . PHP , , . , . :
<?php
if (isset($_COOKIE['C_COOKIE'])) {
} elseif (isset($_GET['C_COOKIE']) || isset($_POST['C_COOKIE'])) {
mail("administrarot@example.com", ", ", $_SERVER['REMOTE_ADDR']);
echo " . ";
exit;
} else {
}
?>
. C_COOKIE . , . , . , register_globals . , , .
That, in general, is all you need to know about global variables in order to successfully and safely use them in your activities. Of course, to say that there is a full guarantee that no one can take advantage of them - crackers are constantly improving their methods and skills. Therefore, it is desirable to limit the use of global variables in the code to the maximum. Fortunately, the structure and construction features of this programming language allow us to achieve this goal. Good luck!