PHP: How to pass variables from PHP to JavaScript

From The Travis van der Font Wiki
Jump to: navigation, search

Boolean

<?php $readOnly = false; ?>

var readOnly = <?php echo json_encode($readOnly);?>;

if (readOnly === false) { /* ... */ }