javascript - 带有 Javascript 弹出窗口的字符串中的 PHP 变量
问题描述
在 /var/www/html/msg.txt 中只有一个词“测试”。
有人可以告诉我为什么这不起作用吗?
echo "<script>alert('$tes');</script>";
完整的php代码:
<?php
$ma="Test";
$tes = file_get_contents("/var/www/html/msg.txt");
echo "$tes"; //works
echo "<script>alert('$ma'); //works
</script>";
//but if this
echo "<script>alert('$tes'); // doesn't work!!!! Why?
</script>";
?>
我该怎么做?
解决方案
问题在于您的 file_get_contents。可能您设置的路径不正确,或者您尝试访问的文件没有正确的权限
推荐阅读
- algorithm - 有界子集和
- angular - 验证小数的角度
- regex - 如何在bash中使用正则表达式查找字符串的特定部分
- android - 导入 SVG 出现错误:`已经为元素“路径”指定了属性“android:fillType”。`
- docker - Docker 构建缓存会自动清除吗?
- ios - 如何在 Swift iOS 中使用 Struct Modal 类中的虚拟值创建数组
- xaml - Flyout 落后于 SecondaryCommands
- javascript - 当我在 react js 中使用这个插件 react-google-maps 设置状态时,onDrag 函数不起作用
- reactjs - React 中的样式化组件,找到对应的组件
- npm - 提高 Azure DevOps npm 构建速度?