Display php output on a txt file Linux command line
If your blacklist.php writes output to standard output, you can run your PHP script like this
php blacklist.php > blacklist.txt
We can do it using file_put_contents
<?phpfile_put_contents('blacklist.txt ', file_get_contents('blacklist.php')); ?>
Another alternative: Use exec()
<?phpexec ('php blacklist.php', $output); file_put_contents('blacklist.txt', $output); ?>
Another alternative:Output redirection to a text file using Command line
In Windows:
C:\xampp\php>php C:\xampp\htdocs\blacklist.php >blacklist.txt
In Linux:
$ php blacklist.php >blacklist.txt
You can use file_put_contents()
:
file_put_contents('your file', 'your data')