Onur K. Onur K. -5 years ago 121
PHP Question

PHP - How to replace $arg with textfile.txt content

I have a .txt file on my web server (locally) and wish to use that .txt content in my PHP block. The .txt file contains a number that is updated by another script on another page, but for this page I just want to pull the number/txt file contents from the file and need to replace with "$savedSession" on this function;


I can echo .txt content with file_get_contents function but just needed to using file content on that php function.

How can I do this?

Thanks so much for replies.

Answer Source

Instead of echoing you can use the = assignment operator to assign the value to a variable.

$variable = file_get_contents('stuff');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download