문제

I am trying to display the contents of a text file inside a div in my view. I found that in php

<?php
    $myfilename = "mytextfile.txt";
    if(file_exists($myfilename)){
      echo file_get_contents($myfilename);
    }
?> 

this code can be used . Is there any such methods in Yii to display the contents inside a text file?

Update

This file is stored under components folder. It cannot be included inside the views section.

도움이 되었습니까?

해결책

readfile()

file_get_contents

You can try these two functions. :)

다른 팁

There are renderFile() method in CController class. Put your text file somewhere at views/files and use that method like

$this->renderFile('/files/filename.txt');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top