Understanding MVC Views in PHP

后端 未结 7 680
生来不讨喜
生来不讨喜 2020-11-22 10:45

I have to seem problems grasping the concept of Views in MVC, they are, according to what I\'ve read, the layer that manages the presentation in the aplication, but many of

相关标签:
7条回答
  • 2020-11-22 11:22

    Different frameworks use different logic to assign variables to view and get its content. Below is a simple example using ob_start() function.

    <?php
         $title = 'Hello...';
         ob_start();
         file_get_contents('view.phtml');
         $viewContents = ob_get_clean();
         echo $viewContents;
    
    ?>
    
    //view.phtml
    <b>Hello the title is <?php echo $title; ?></b>
    

    Hope this answer your question...

    0 讨论(0)
提交回复
热议问题