简体   繁体   English

引用 JQuery / JavaScript 时使用 PHP 打印 ZC1C425268E6838541AB5074F7A7

[英]Quotes in JQuery / JavaScript when using PHP print function

I'm trying to debug someone's code and have hit a bit of a rookie error.我正在尝试调试某人的代码并且遇到了一些新手错误。

Now while this works on Xserve (or at least it kindly ignores it), when running on a linux server it refuses to co-operate and knocks out a function lower down.现在,虽然这在 Xserve 上有效(或者至少它善意地忽略它),但在 linux 服务器上运行时,它拒绝合作并击倒 function 较低的位置。

I'm pretty sure what I need to do here is address the quotes: the scope of the quotes seems to be wrong - the first double quote links to the third and the second to the fourth.我很确定我需要在这里做的是解决引号:引号的 scope 似乎是错误的——第一个双引号链接到第三个,第二个链接到第四个。 Any ideas very very welcome!非常欢迎任何想法!

<?php foreach ($years as $id => $title) : ?>
$("#<?php print $id ?>_both").click(function() {
$(".<?php print $id ?>.g, .<?php print $id ?>.b")
.attr("checked", $("#<?php print $id ?>_both").attr("checked"));
});
<?php endforeach; 

The quotes look okay (awful, but okay).报价看起来不错(糟糕,但还可以)。 Are you sure you aren't missing an end php (last line):你确定你没有错过结尾 php (最后一行):

<?php foreach ($years as $id => $title) : ?>
$("#<?php print $id ?>_both").click(function() {
$(".<?php print $id ?>.g, .<?php print $id ?>.b")
.attr("checked", $("#<?php print $id ?>_both").attr("checked"));
});
<?php endforeach; ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM