php - 能不能给讲讲 用的框架里的Data模式是怎么把数组转换成对象的?
如:
1 2 3 4 5 6 | $questions = $this ->questionModel->listQuestions();
$this ->questions = new Data_Question( $questions );
$this ->view->render( 'questions.php' );
|
到View中我们就可以操作Data_Question对象了
1 2 3 4 | <?php foreach ( $questions as $q ): ?>
<h2><a href= "<?php $q->url(); ?>" ><?php $q ->title(); ?></a></h2>
<p><?php $q ->summary(100, '...' ); ?></p>
<?php endforeach ; ?>
|
我想知道这个Data_Question是如何实现的