我是比较新的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