Home > Backend Development > PHP Tutorial > 折腾1天,js调用php不成功,求助!

折腾1天,js调用php不成功,求助!

WBOY
Release: 2016-06-23 14:02:29
Original
853 people have browsed it

几个简单的语句
index.html:


<script> <br /> </script>


test.php:
echo "document.write('你好');";
?>

怎么显示不了‘你好’的结果?网上搜了一天,标点符号问题、php输出js问题等等,还是没成功!显示行1、字符1错误。我的空间是appach+php+mysql,php运行正常。是不是哪个地方参数还需设置?拜求大佬指点迷津。


回复讨论(解决方案)

你的 test.php 是 utf-8 编码的吧?
去掉 BOM 头就可以了

试了一下,还是不成功。php是用Dreamweaver8编译的,上贴是GB2312。现改选UTF8,没保留签名(应当去掉了BOM头?)。如下格式:
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档


echo "document.write('nihao');";


仍旧行1,字符1错误。是不是还有什么地方设置问题?

<script> <br /> document.write('nihao'); <br /> </script>

要写那么多干什么
php文件直接写:
echo "document.write('nihao');"; ?>

要写那么多干什么
php文件直接写:
echo "document.write('nihao');"; ?>

PHP 里面可以直接这样写吗??

echo "<script>"; ?> <br /> <br /> 要这样才可以吧 </script>

感谢诸位给我了思路启发,jordan102说的对,我直接打开DM模板就用,一堆东西影响,删掉就好。再次感谢!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template