<script>
$(document).ready(function(){
<?php
echo 'var timeLeft = 12796;';
?>;
console.log(timeLeft);
});
</script>
How is jquery acessing the php variable because to create a php variable we use $ and here it is using var?
Now how can i correct the below code because its showing me error in the console?
<script>
var currentDate= <?php echo 'strtotime("now")' ; ?>;
console.log(currentDate);
</script>
Here i am using strtotime function instead of simple echoing a numbe
If the side is being processed through PHP (on the server) you can just use an
echoAfter PHP has processed the page it is just regular javascript as if you wrote it manually.
You can also imagine the following example:
Save it as hello.php inside of your web servers document root and call it in browser.