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.

Était-ce utile?

La solution

readfile()

file_get_contents

You can try these two functions. :)

Autres conseils

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');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top