Associate
- Joined
- 27 Apr 2004
- Posts
- 2,377
I've written a script in php that's run from the command line version of php. The script itself runs fine but part of its job is to produce an output which is written to a file.
When the script has finished running, I ask the user to enter a file name to save as using the following:
However it simply does not work and tells me the filename [fgets(STDIN)] is not valid.
I've tried the following but still get the same error.
I know that fgets(STDIN) is working because I use it in other parts of the script. What am I doing wrong?
It may be worth me mentioning that I'm using version 4 something, and I'm aware file_put_contents() is new in php 5; however, I define the function file_put_contents() within the script and I know it works.
Thanks, null
When the script has finished running, I ask the user to enter a file name to save as using the following:
PHP:
file_put_contents(fgets(STDIN), "(file data goes here)");
However it simply does not work and tells me the filename [fgets(STDIN)] is not valid.
I've tried the following but still get the same error.
PHP:
$filename = fgets(STDIN);
file_put_contentss($filename, "(file data goes here)");
I know that fgets(STDIN) is working because I use it in other parts of the script. What am I doing wrong?
It may be worth me mentioning that I'm using version 4 something, and I'm aware file_put_contents() is new in php 5; however, I define the function file_put_contents() within the script and I know it works.
Thanks, null
