I am trying to do this
$fp = fopen('all.js', 'w');
fwrite($fp, 'sddddddddddddddddddddd');
echo "<script src=\"/inc/all.js\" type=\"text/javascript\"></script>";
but the file is always empty…can you use fwrite on a js file and write to it…i checked permissions and all is good there…any ideas?
fwrite couldn’t care less if you’re writing text, js, php, or raw binary garbage. It just outputs what you tell it to.
The problem is that you’re writing out to
all.js, but are refering to/inc/all.jsin your script tag. Unless your script’s current-working-directory is set to whatever directory the URL/incmaps to on your server, you’re writing in one place, but reading from another.