I m trying to run php script using cmd
CMD Code
"C:\wamp\bin\php\php5.4.16\php.exe" -f "C:\wamp\www\file\test.php"
PHP Code
$fileLocation = getenv("DOCUMENT_ROOT") . "/file/myfile.txt";//OR $fileLocation = "myfile.txt"
$file = fopen($fileLocation,"w");
$content = "Your text here";
fwrite($file,$content);
fclose($file);
Here problem is file is not created. If I run this file in browser then file is generate. user is administrator .
getenv("DOCUMENT_ROOT")renders anything useful... Echo that value and check if the result is what you were hoping it to be.