I am trying to learn javascript. I have the following code:
<?php
$a = true;
$b = false;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
window.variable = {
a: <?php $a ? true : false ?>,
b: <?php $b ? 1 : null ?>
}
console.log(variable);
</script>
</body>
</html>
Javascript is not accepting the true
, fasle
, 1
or null
I am getting the Uncaught SyntaxError: Unexpected token ,
and it is displaying the following in the chrome dev tools:
<script>
window.variable = {
a: ,
b: }
console.log(variable);
</script>
where am I going wrong??