use json_encode()
. It'll convert from native PHP types to native Javascript types:
var myvar = <?php echo json_encode($my_var); ?>;
and will also take care of any escaping necessary to turn that into valid javascript.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…