javascript - How to use Super Global PHP variables inside JS file -
this question has answer here:
- how pass variables , data php javascript? 17 answers
in javascript file i've if statement , code inside it. , i'm trying use super global variable inside js function.
here php code embedded inside javascript function:
if(typeof window.history.pushstate == 'function') { window.history.pushstate({}, "hide", '<?php echo $_server['php_self'];?>'); }
$_server['php_self']
variable stands 3-parametr of js function.
one more thing: when write code inside somefile.php it's working fine. i'm gonna put partition of code inside external js file , include it. how can achieve this?
as long have php parse - appending .php @ end of filename, if you're using apache - should fine. can load javascript files end in php <script src="test.js.php" />
.
Comments
Post a Comment