Answers for "how to write php code in js file"

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
0

how to write php in script file

<?php
$phpToJsVars = [
  'value1' => 'foo1',
  'value2' => 'foo2'    
];
?>
Posted by: Guest on October-17-2020

Code answers related to "how to write php code in js file"

Browse Popular Code Answers by Language