3 回答

TA貢獻(xiàn)1998條經(jīng)驗 獲得超6個贊
該register_globals指令:
register_globals是一個內(nèi)部PHP設(shè)置,它將$_REQUEST數(shù)組的元素注冊為變量。如果以POST或形式提交值GET,則可以通過PHP腳本中的變量(以輸入字段的名稱命名)自動訪問該輸入的值。
換句話說,如果您提交的表單包含username文本字段,($username === $_POST['username'])則腳本最開始的表達(dá)式將返回true。
它的臭名昭著歸因于它打開了許多安全漏洞的事實,特別是對于從安全角度而言遵循嚴(yán)格編碼風(fēng)格之外的任何事物的人們。
經(jīng)典示例:
if(user_is_admin($user))
{
$authorized = true;
}
if($authorized)
{
// let them do anything they want
}
現(xiàn)在,如果您在Web瀏覽器中訪問了該腳本并且服務(wù)器已register_globals打開,則只需將其附加?authorized=1到URL 即可啟用上帝模式!
該global關(guān)鍵字:
global 是與register_globals無關(guān)的關(guān)鍵字。
這是一個用法示例:
$foo = 'bar';
baz();
function baz()
{
echo $foo; // PHP warns you about trying to use an uninitialized variable
// and nothing is output (because $foo doesn't exist here)
}
buzz();
function buzz()
{
global $foo; // Enables the use of $foo in this scope
echo $foo; // Prints 'bar' to screen
}
- 3 回答
- 0 關(guān)注
- 1233 瀏覽
添加回答
舉報