You can try these two functions. :)
How to Display the Text contents of a text file in yii?
-
26-06-2023 - |
문제
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.
해결책
다른 팁
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');
제휴하지 않습니다 StackOverflow