Answers for "can i write javascript in php file"

PHP
2

write in a file using php

<?php
$myfile = fopen("file_name.txt", "w") or die("Unable to open file!");
$txt = "Hello world\n";
fwrite($myfile, $txt);
$txt = " Php.\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
Posted by: Guest on June-05-2020
0

write php in javascript

<script type="text/javascript">
	var myString = '<?php echo 1+1; ?>';
</script>
Posted by: Guest on August-02-2021
0

how to write php in script file

<script type="text/javascript" src="YourFunctions.js"></script>
<script type="text/javascript">
    functionOne(<?php echo implode(', ', $arrayWithVars); ?>);
    functionTwo(<?php echo $moreVars; ?>, <?php echo $evenMoreVars; ?>);
</script>
Posted by: Guest on October-17-2020

Code answers related to "can i write javascript in php file"

Browse Popular Code Answers by Language