Only the JSON_ENCODE works for a variable from PHP to javascript
In the following, why
echo 123 DOES NOT WORK?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
$(document).ready(function () {
var jsvar = <?php
echo json_encode(123); ?>;
<---- //WORKS!!!
var jsvar = <?php
echo 123; ?>;
// NOTHING HAPPENS!!!
alert('ak=='+jsvar);
<---- //WORKS!!!
console.log(jsvar);
// NOTHING HAPPENS!!!
});//$document
</script>
<style>
</style>
</head>
<body bgcolor="#E6E6E6">
</body>
</html>