PHP处理form时出了问题怎么办啊?~~
各位大虾,小弟在用PHP处理FORM时,为什么不能接收到变量的值呢?比...
作者 刀锋战士2 发布于 2003-08-02 分类:php基础编程
想问一下PHP程序首页调用的问题。
————————————————————
一般只要在HTML页面中放一个:<script src=文件名.php></script>
然后在被调用的文件中放下面几个字就可以显示了:
document.write("要显示的内容");
—————————————————————
而一般人都是这么做的。
但是我把document.write("要显示的内容");
放在PHP程序中做主页调用怎么会出现错误。
简单的实际例子如下:
————————————————————————————————
<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo"$c";
?>
document.write("<?echo $c;?>");
————————————————————————————————
我又试了一下,用最简单的:
<?phpecho"document.write(999)";?> 这样都会错误。
<?echo"document.write(999)";?> //这样不要php 三个字就居然就可以正确显示了。JS真是有点烦。而且不是一般的烦!
<? $a=789;$b=abc;$c=$a.$b;echo"document.write("$c")";?> //最后这样也可以了
————————————————————————————————
<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo"$c";
echo "document.write("$c")";
?> //这样不行,
<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo "document.write("$c")";
?> //去掉echo"$c";这样就OK。
————————————————————————————————
<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo"$c";
?>
document.write("<?echo $c;?>"); //这样不行!
<?php
$a=abc;
$b=ggg;
$c=$a.$b;
?>
document.write("<?echo $c;?>"); //去掉echo"$c";这样就OK。
————————————————————————————
不知道JS调用PHP需要注意哪些方面的问题。或者JS的语法风格上有什么要求。
逛论坛交流:!!html页调用php程序问题!!
有人看吗?顶!
[PHP]<?phpecho"document.write(999)";?> 这样都会错误[/PHP]
当然会错了,你这样写相当于 <? phpecho"document.write(999)";?>
[PHP]<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo"$c";
echo "document.write("$c")";
?> //这样不行,[/PHP]
在我的电脑上运行的结果是
abcgggdocument.write("abcggg")
[PHP]<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo"$c";
?>
document.write("<?echo $c;?>"); [/PHP]
在我的电脑上运行结果是
abcgggdocument.write("abcggg");
[PHP]不能用JS调用的原因:你的JS语法错误,所有的输出应该是:document.write("XXXXXX");[/PHP]
刚才的那个应该写在
<?php
$a=abc;
$b=ggg;
$c=$a.$b;
echo"document.write("$c");";[/COLOR]
?>
document.write("<?echo $c;?>");
2 条回复
回复