Question

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.

Was it helpful?

Solution

readfile()

file_get_contents

You can try these two functions. :)

OTHER TIPS

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');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top