带有php变量的HTML类名

带有php变量的HTML类名,php,html,Php,Html,我有一个巨大的页面,但我已经在一个JS小提琴重建错误 这是有错误的行 它不是将类名作为变量的相等值来读取吗 我遗漏了什么还是您不能这样做?将您的HTML更改为 <body> <a href="http://jquery.com/">jQuery</a> <?php $env = "env" ?> <ul class="chk-container"> <li><input class

我有一个巨大的页面,但我已经在一个JS小提琴重建错误

这是有错误的行

它不是将类名作为变量的相等值来读取吗

我遗漏了什么还是您不能这样做?

将您的HTML更改为

<body>
<a href="http://jquery.com/">jQuery</a>
<?php $env = "env" ?>
        <ul class="chk-container">
           <li><input class="selecctall" type="checkbox"> Selecct All</li>
           <li><input class="<?php echo $env;?>" type="checkbox" > This is Item 1</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 2</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 3</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 4</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 5</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 6</li>
           <li><input class="checkbox2" type="checkbox" > Do not select this</li>

        </ul>
</body>

问题是,您没有关闭php标记

close,您是否已将代码复制并粘贴到JSFIDLE中?因为您没有关闭第一个PHP标记。JSFIDLE无法运行PHP。你真的遇到PHP致命错误了吗?没有,我什么都没有,是的,我现在已经更正了复制粘贴问题。对不起,那只是复制粘贴问题,不是真正的问题。请检查这部分。有什么区别吗?
<body>
<a href="http://jquery.com/">jQuery</a>
<?php $env = "env" ?>
        <ul class="chk-container">
           <li><input class="selecctall" type="checkbox"> Selecct All</li>
           <li><input class="<?php echo $env;?>" type="checkbox" > This is Item 1</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 2</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 3</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 4</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 5</li>
           <li><input class="checkbox1" type="checkbox" > This is Item 6</li>
           <li><input class="checkbox2" type="checkbox" > Do not select this</li>

        </ul>
</body>