我是比較新的PHP和有一些體面的成功,但我遇到了這個問題:創建新實例失敗PHP
如果我試圖創建類GenericEntryVO的新實例,我得到一個500錯誤與幾乎沒有有用的錯誤信息。但是,如果我使用通用對象作爲結果,則不會出現錯誤。我希望能夠將此對象作爲GenericEntryVO進行強制轉換,因爲我正在使用AMFPHP將序列化數據與Flex客戶端進行通信。
我讀過一些不同的方法來創建PHP但對於一個類Foo典型的「公共函數foo()」的構造被推薦爲PHP 5.4.4
//in my EntryService.php class
public function getEntryByID($id)
{
$link = mysqli_connect("localhost", "root", "root", "BabyTrackingAppDB");
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT * FROM Entries WHERE id = '$id' LIMIT 1";
if ($result = mysqli_query($link, $query))
{
// $entry = new GenericEntryVO(); this is where the problem lies!
while ($row = mysqli_fetch_row($result))
{
$entry->id = $row[0];
$entry->entryType = $row[1];
$entry->title = $row[2];
$entry->description = $row[3];
$entry->value = $row[4];
$entry->created = $row[5];
$entry->updated = $row[6];
}
}
mysqli_free_result($result);
mysqli_close($link);
return $entry;
}
//my GenericEntryVO.php class
<?php
class GenericEntryVO
{
public function __construct()
{
}
public $id;
public $title;
public $entryType;
public $description;
public $value;
public $created;
public $updated;
// public $properties;
}
?>
再次
請啓用錯誤記錄/讀取錯誤日誌以獲取「錯誤500」後面的真實錯誤消息。這應該引導你前進。 – eis
你能分享一下這個「很少或沒有幫助的錯誤信息」嗎? –
@eis它看起來很難找到GenericEntryVO.php文件?這很奇怪,因爲我在我的services.php文件中的其他方法使用GenericEntryVO類沒有問題。我也會粘貼它。 不能在這裏發表的代碼,因爲最大的字符,但這裏有引擎收錄鏈接: 錯誤日誌: [鏈接](http://pastie.org/5371978) 整個服務類: [鏈接]( http://pastie.org/5371989) – jusopi