php - 如何注释掉带有 PHP 的 HTML 行?
问题描述
我知道答案很简单,但我在任何地方都找不到。如何禁用这条线?我试过了,但 id 不起作用
//
<!-- -->
/* */
<a class="switch" data-mode="<?php echo Session::cookieExists("myTheme", "dark") ? "dark" : "light";?>">
解决方案
<?php
// <-- this is a comment in PHP, java and javascript (prob others) - NOT HTML
/* this is also a type of comment in PHP, java, javascript and css (and prob others) */
?>
<!-- This is an html comment
The PHP code inside it will still run, but the result will be commented out. -->
<!-- <a class="switch" data-mode="<?php echo Session::cookieExists("myTheme", "dark") ? "dark" : "light";?>"> -->
<!-- This is the element with the PHP code inside commented out -->
<a class="switch" data-mode="<?php /* echo Session::cookieExists("myTheme", "dark") ? "dark" : "light"; */ ?>">
推荐阅读
- javascript - 阻止输入类型 date null 时更改边框颜色和消息 html 验证
- three.js - 在 React-Three-Fiber 中移动平面顶点位置的正确方法
- oauth-2.0 - 使用带有 OAuth2.0 客户端凭据的 Azure EWS 发送电子邮件
- javascript - 如何将多个类名添加到 nextjs 元素
- google-sheets - 将html表格行提取到谷歌表格
- python - Python`urllib3`:突然“证书验证失败:证书已过期”错误
- python - 截至 2021 年,Google Colab 使用的是哪个 Python 版本?
- c# - 发布操作在控制器中不起作用但在另一个控制器中起作用
- sql - 如何在特定值更改 SQL/Hive 后播种/插入特定值
- javascript - 当某些节点为空时,二叉树搜索不返回匹配值