<?php //php code.. $some_var ='value'; ?> <!doctype html> <html lang='en'> <head> <meta charset='utf-8' /> <title>Page Title</title> <script> var js_var ='<?php echo $some_var; ?>'; </script> </head> <body> Page content.. <script src='external_file.js'></script> </body> </html>
Now, in the script from external_file.js we can use the js_var
(it contains the value of the php $some_var).
2. For example, in external_file.js:
alert(js_var); // value
The javascript variable must be defined before the external js file is included.
<table><tr> <th>Title 1</th> <th>Title 2</th> </tr></table>
.some_class { line-height: 150%; }
document.getElementById("id_button").onclick = function(){ window.open("http://coursesweb.net/"); }
$ar_dir = scandir("dir_name"); var_export($ar_dir);