Are you first timer at Why not join us and start exchange your programming knowledge with everyone. Register today!

PHP - Using js into PHP code

0 votes
added Dec 17, 2020 in PHP by lcjr Second Warrant Officer (5,520 points)
   $myScript = file_get_contents('your-script.js');
   echo "<script>".$myScript."</script>";


1 Response

0 votes
responded Dec 17, 2020 by lcjr Second Warrant Officer (5,520 points)
 // Break the echo into few parts to avoid conflicts when using single or double quote in JS
  echo '<script type="text/javascript">';
  echo 'document.write("Hey world!")';
  echo '</script>';

?> - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.