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?
This will create file called script.js
and contains your JS statements:
$script="$(document).ready(function(){alert('hai');});";
$fileName="script.js";
file_put_contents($fileName, $script);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With