I have a problem with PHP and Javascript variable communication. I have this code:
<?php
$php_var = \'lol\';
?>
<html>
<script type=\"text/javascript\" charset=\"utf-8\">
var php_var = \"<?php echo $php_var; ?>\";
alert(php_var);
</script>
</html>
This code does not work (as intended) for some reason. I cannot get the PHP variable\’s value passed down to Javascript variable. For some reason, Javascript completely ignores the php tags and assigns php_var a value of \”\”. So it alerts the literal php code I put it as.
What am I doing wrong? I have been stuck on this problem for 3 hours. Is it my server\’s problem? (Using web hosting, dedicated). Thank you





Rating:
The post PHP variables to javascript, does not work appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/php-variables-to-javascript-does-not-work.html
No comments:
Post a Comment