正确的源$ C $ C,但我得到了解析错误:语法错误,意外'}“ [英] Correct source code, but I got parse error: syntax error, unexpected '}'
问题描述
现在我想建立一个网站的本地镜像。我有这个网站的整个数据库和源$ C $ C。
该网站运行流畅的服务器,但是当我尝试在本地访问该网站的login.php中,我得到了解析错误:语法错误,意外的}。
我检查的login.php源$ C $ C,而且应该没有问题的语法。我也尝试过不同版本的PHP,但一次又一次得到了相同的语法错误。任何人都可以帮我看看问题出在哪里?
Now I am trying to set up a local mirror of a website. I have whole database and source code of this website. The website runs smoothly in the server, but when I try to visit login.php of the website locally, I got the parse error: syntax error, unexpected '}'. I checked source code of login.php, and there should be no problem with syntax. I also tried different versions of php, but got the same syntax error again and again. Can anybody help me find where the problem is?
在PHP的login.php部分的源$ C $ C:
The source code of php part in login.php:
<?php
if ($form->Value("email") != "")
?>
<script>document.getElementById('email').value = "<?php echo $form->Value("email"); ?>"</script>
<?
if ($form->Value("pass") != "")
?>
<script>document.getElementById('pass').value = "<?php echo $form->Value("pass"); ?>"</script>
<?
$fields = array("email", "pass");
for ($i=0 ; $i<count($fields) ; $i++) {
if ($form->Error($fields[$i]) != "") {
?>
<script>DisplayMsg(document.getElementById("<?php echo $fields[$i]; ?>"), "<?php echo $form->Error($fields[$i]); ?>", false);</script>
<?php
}//Parse error here: syntax error, unexpected '}'
else {
?>
<script>DisplayMsg(document.getElementById("<?php echo $fields[$i]; ?>"), "", true);</script>
<?php
}
}
?>
我使用的XAMPP设置我的本地环境。
我是新来PHP,让我知道如果我需要发布更多信息。
I am using XAMPP to set up my local environment. I am new to php, let me know if I need to post more information
推荐答案
这是可能的,因为的当你在本地测试short_open_tag的值为是禁用的。此设置控制是否&LT ;? ?方式&gt;
其它标签中的分析过程中PTED为PHP间$ P $
This is likely because short_open_tag is disabled when you test locally. This setting controls whether or not <? ?>
among other tags are interpreted as PHP during parsing.
其结果是,该块
<?
$fields = array("email", "pass");
for ($i=0 ; $i<count($fields) ; $i++) {
if ($form->Error($fields[$i]) != "") {
?>
时,从来没有像PHP执行。
is never executed as PHP.
因此,在这里使用时结束花关闭什么:
Consequently, the closing brace closes nothing when used here:
<?php
}//Parse error here: syntax error, unexpected '}'
else {
?>
这就是为什么你解析错误在一个案件而不是其他。
That is why you get the parsing error in one case but not the other.
这篇关于正确的源$ C $ C,但我得到了解析错误:语法错误,意外'}“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!