javascript - 如何在javascript中编写字符串和回显的比较代码?
问题描述
<script>
if (<? echo $temp =="xxxxx" ?>){ //the problem is in the if clause
console.log("yyy");
}
<script>
它在控制台中说“)”的意外标记
解决方案
你混合 php 和 javascript。我猜你想在客户端进行比较。试试这个代码:
<script>
var tmp = "<? echo $temp ?>";
if (tmp =="xxxxx" ) {
console.log("yyy");
}
<script>
推荐阅读
- c++ - 减少 C++ 中的运行时间
- amazon-web-services - 我如何知道 s3 存储桶无服务器用于部署?
- python-3.x - 预期输入的形状为 (150,) 但得到的数组形状为 (1,)
- html - 我可以在循环播放的 HTML 文档中插入多个音频文件吗
- markdown - 在代码围栏上的降价中添加类的正确方法是什么
- python - 在 Google Colab 中使用 pyspark
- android - 如何获取android系统大小?
- driver - 如何识别 i2c 地址的设备?
- java - 葡萄牙语字符(如ã、ó)读作“?” 当我升级到 ojdbc8.jar 时从数据库中获取。它与 ojdbc6.jar 一起正常工作。使用JBoss7.0
- apache-kafka - Kafka-console-producer 返回主题超时错误