我有以下代码:
<?php
if ($zweck == "buchhaltung") {
echo <<<EOF
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#$grid_name").jqGrid({
url: 'modules/mod_jqgrid/ex_get3.php?tb=$tb'
.....
</script>
EOF;
};
?>
...似乎无法正确渲染。我们不能在 JavaScript 代码中的 heredoc 中使用 PHP 变量,就像我在倒数第二行使用它一样吗?
在最后一行,我在 PHP 变量 $tb 周围使用了“'”。这个语法正确吗?
以下代码在 heredoc 中作为 JavaScript 代码:
dataInit:function(el){
$(el).datepicker({dateFormat:'dd.mm.yy'});
},
defaultValue: function(){
// Maybe PHP "thinks" that $(el) is a PHP variable?
var currentTime = new Date();