I'm using fread to read a text file, and this text file has variables in it. How do I get PHP to parse those variables?

Thanks,
Chris

    well... You could just create the text file as a PHP file, and include it... That would be the easiest solution, although there is a function in php that would take a string, and execute it as php code... don't really remember which function it was though, was trying to find it... but couldn't. At any rate, try my first suggestion, probably would work better.

      in case you use apache, you can tell the server to parse .txt files using .htaccess...

        Originally posted by WinterDragon
        well... You could just create the text file as a PHP file, and include it... That would be the easiest solution, although there is a function in php that would take a string, and execute it as php code... don't really remember which function it was though, was trying to find it... but couldn't. At any rate, try my first suggestion, probably would work better.

        Prolly thinking of eval()?

        originally posted by crosbystillsnas{h}
        in case you use apache, you can tell the server to parse .txt files using .htaccess...

        or httpd.conf. But really now, TXT files? 😃

          eval() or parse_ini_file() are your best bets.

          But if its valid PHP code... why don't you just include the text files?

            Yeah, guys, but *.txt is viewable by any browser. So, why would you want your code available for public viewing?

              Originally posted by dalecosp
              Yeah, guys, but *.txt is viewable by any browser. So, why would you want your code available for public viewing?

              (we) dont get it. if its parsed, its not visible... 😕

                OK, yeah, if it's parsed; forgot about that. :eek: I likely will never ask Apache to parse .txt; I imagine that asking it to parse .html is enough of a boring process, eh?

                  Write a Reply...