【新手有關問題】為什麼一個變數沒有經過取值就直接使用了

來源:互聯網
上載者:User
【新手問題】為什麼一個變數沒有經過取值就直接使用了?
下面的代碼中 $photo 為什麼沒有經過$_POST取值便可以直接使用了?而象$id之類的要經過$_POST取值後才可以使用?

(這段代碼是一段 處理另一個註冊頁面傳來資料 的代碼,在另一個註冊頁面中有如下對應代碼: )

// 取得網頁的參數
$id=$_POST[ 'id '];
$name=$_POST[ 'name '];
$password=$_POST[ 'password '];

...

if ($photo <> " "){
$fp=fopen($photo, "r ");
$data=addslashes(fread($fp,filesize($photo)));
}
$password=md5($password);
$sql= "insert into member (id, name, password, sex, email, oicq, homepage, city, address, zip, tel, edu, introduction, interest, birthday, photo, regtime, regip) values( '$id ', '$name ', '$password ', '$sex ', '$email ', '$oicq ', '$homepage ', '$city ', '$address ', '$zip ', '$tel ', '$edu ', '$introduction ', '$interest ', '$birthday ', '$data ', '$now ', '$ip ') ";

...

------解決方案--------------------
估計你的php.ini 裡register_globals 狀態為on吧?
------解決方案--------------------
register_globals 狀態為on
photo他忘記用$_POST取值了
------解決方案--------------------
$photo 是沿用的以前的規則,以前的PHP可以不用$_POST 而直接取值即可。
$XXX也是可以直接使用的。
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.