См. Прикрепленный код.по какой-то причине json_encode()
возвращает пустую строку.
Я вызываю ее с помощью $jv = Video::ConvertToJson($video);
Используя точки останова, я убедился, что $video
не равно нулю и т. д.
(с использованием PHP 5.3)
Есть идеи?
thx
class Video
{
private $ID;
private $Title;
private $ViewCount;
private $Description;
private $IsEmbeddable;
private $IsPrivate;
function __construct($id = 0, $title = '', $viewcount=0, $description='', $isembeddable=1, $isprivate=0){
$this->ID = $id;
$this->Title = $title;
$this->ViewCount = $viewcount;
$this->Description = $description;
$this->IsEmbeddable = $isembeddable;
$this->IsPrivate = $isprivate;
}
/**
*
* Converts a Tfyoutubevideo into a json object
* @param models\TfYoutubevideos $tfv
*/
public static function ConvertToJson(models\TfYoutubevideos $tfv){
$v = new Video();
$v->ID = $tfv->getId();
$v->Title = $tfv->getVideotitle();
$v->ViewCount = $tfv->getVideoviewcount();
$v->Description = $tfv->getVideoDescription();
$v->IsEmbeddable = $tfv->getVideoIsEmbeddable();
$v->IsPrivate = $tfv->getVideoIsPrivate();
$vj = json_encode($v);
return $vj;
}
}