I have a code like this which is created using php
<?php
$script="$(document).ready(function(){alert('hai');});";
?>
As far as I have referred in other websites, they have used fopen() and fwrite() to open a text file and write in it. I don't want txt file to be created.Can I create a script file say script.js that contains data in the $script variable using php?
srcpoint to your php script. Make sure to do aheader('Content-Type: text/javascript');before hand so browser will interpret it correctly.