我已經寫了下面的代碼:問題與PHP
$release_id = intval(filter_var($_GET["rid"],FILTER_SANITIZE_STRING));
$query = "select * from press_releases where id = {$release_id}";
$result = $db->query($query);
$row = $result->fetch_assoc();
list($id, $short_description, $description, $created_date) = $row;
$db->close();
,我使用諸如$description
,$short_description
裏面的html標籤的變量,但沒有任何顯示。如果我使用下面的代碼,這是除了list()
功能相同:
$release_id = intval(filter_var($_GET["rid"],FILTER_SANITIZE_STRING));
$query = "select * from press_releases where id = {$release_id}";
$result = $db->query($query);
$row = $result->fetch_assoc();
$id = $row["id"];
$short_description = $row["short_description"];
$description = stripslashes(html_entity_decode($row["description"]));
$created_date = $row["created_date"];
$db->close();
它完美的作品。基本上list()
函數不能分配來自$row
數組的值。
我不明白爲什麼?
現在有意義。它已經在文檔中說過了,但我看不到它:http://blog.csdn.net/manual/en/function.list.php – Tarik
@Braveyard:另外,'list()'以相反的順序賦值(請參閱下面的警告)。 –