几个简单的语句
index.html:
<body>
<script src="test.php">
</script>
</body>test.php:
<?php
echo "document.write('你好');";
?>怎么显示不了‘你好’的结果?网上搜了一天,标点符号问题、php输出js问题等等,还是没成功!显示行1、字符1错误。我的空间是appach+php+mysql,php运行正常。是不是哪个地方参数还需设置?拜求大佬指点迷津。js 调用 php 失败
index.html:
<body>
<script src="test.php">
</script>
</body>test.php:
<?php
echo "document.write('你好');";
?>怎么显示不了‘你好’的结果?网上搜了一天,标点符号问题、php输出js问题等等,还是没成功!显示行1、字符1错误。我的空间是appach+php+mysql,php运行正常。是不是哪个地方参数还需设置?拜求大佬指点迷津。js 调用 php 失败
去掉 BOM 头就可以了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
echo "document.write('nihao');";
</body>
</html>
仍旧行1,字符1错误。是不是还有什么地方设置问题?
document.write('nihao');
</script>
php文件直接写:
<?php
echo "document.write('nihao');"; ?>
PHP 里面可以直接这样写吗??<?php
echo "<script type="text/javascript" document.write('nihao'); </script>"; ?>要这样才可以吧