181
rated 0 times
[
184]
[
3]
/ answers: 1 / hits: 25402
/ 13 Years ago, fri, april 1, 2011, 12:00:00
I've run into an odd issue in a PHP script that I'm writing-- I'm sure there's an easy answer but I'm not seeing it.
I'm pulling some vars from a DB using PHP, then passing those values into a Javascript that is getting built dynamically in PHP. Something like this:
$myvar = (bool) $db_return->myvar;
$js = <script type=text/javascript>
var myvar = . $myvar . ;
var myurl = 'http://someserver.com/ajaxpage.php?urlvar=myvar';
</script>;
The problem is that if the boolean value in the DB for myvar is false
, then the instance of myvar in the $js is null, not false
, and this is breaking the script.
Is there a way to properly pass the value false
into the myvar variable?
Thanks!
More From » php