gpt4 book ai didi

php - 页面仅在 PHP 5.3.1 上显示语法错误,但在 5.2.6 上正常

转载 作者:可可西里 更新时间:2023-10-31 23:55:15 28 4
gpt4 key购买 nike

我有两台开发服务器,一台是 PHP 5.3.1 版,它在我的主要开发机器上,用作模拟网络服务器的笔记本电脑上有 PHP 5.2.6 版。

使用 PHP 5.2.6 版本托管的索引页面将正确显示该页面。托管在 PHP 5.3.1 版上的页面没有。

我收到一条错误消息:

Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\Greek\index.php on line 92

我附上了下面的代码。 (但是,我必须警告你它很大,我找不到简单地附加文件或类似东西的方法,所以我最好把所有的都放在这里。对此深表歉意。)

我用谷歌搜索过类似的事情以前是否发生过,但我似乎找不到任何东西。我想我应该在这里问。

但如有任何帮助或指导,我们将不胜感激。

<?php
include_once( 'admin_dataHandler.php' );

// Lets have a handle on the data connection to the data base.
// The file must be edited so that it's pointing to the correct data base.
$dataHandler = new DataConnection();

session_start(); // This connects to the existing session

$msg = "";
if ( $_SESSION['question_id'] ){
$question_id = $_SESSION['question_id'];
}else{
$question_id = 1; /* Find first question */
}
// Debugging only...
//echo $question_id;
$answer = "";
if ( $_REQUEST['action'] ){
// an action was requested..
$action = $_REQUEST['action'];
if ( $action == "answer" ){
if ( $_REQUEST['answer'] ){
$answer = $_REQUEST['answer'];
if ( $dataHandler->checkGreekWordAnswer( $question_id , $answer ) ){
/* Check to see if the answer was correct? */
$question_id = $dataHandler->getNextGreekWordQuestion( $question_id ); /* Find next question */
$answer = "";
$msg = "correct, moving on to next question.";
// then navigate to the next word.
}else{
$msg = "Incorrect. For help hit the hint button";
}
}
}else if ( $action == "next" ) {
$qid = $question_id;
$question_id = $dataHandler->getNextGreekWordQuestion( $question_id );
if( $question_id == null ){
$msg = "There are no more questions in this quiz";
// Keep the user where they're at....
$question_id = $qid;
}
}else if ( $action == "back" ){

$question_id = $dataHandler->getPreviousGreekWordQuestion( $question_id );
//echo "Current question id is " .$question_id;
if( $question_id == null ){
//echo "Something's wrong here...";
$msg = "You're at the beggining of the quiz.";
$question_id = 1;
}
}else if ( $action == "hint" ){
$msg = $dataHandler->getHint( $question_id );
if( $msg == null ){
$msg = "There are no hints for this question. Sorry";
}
}
}
$question = $dataHandler->getGreekWordQuestion( $question_id );
$_SESSION['question_id'] = $question_id;

/** Build the HTML page that's going to be the front end of the quiz.*/
?><html>
<head>
<!-- CSS STUFF HERE....-->
<link rel="stylesheet" type="text/css" href="layout.css">
<script type="text/javascript" src="translator.js"></script>
<title>Welcome to the Greek Quiz</title>
</head>

<body>
<div id="header-block">
<img>
Welcome to the Biblical Greek Quiz
</div>
<? if ( $question_id == -1 ) { ?>
<!-- this needs to be a java scripty pop up
and this H1 section needs to be in red...-->
<h1>You win!</h1>
<? }else{ ?>
<div id="quiz-section">
<span class='question'><?php echo $question; ?></span>
<form action='index.php' method='post'>
<input type='text' size='20' name='answer' id='greekAnswer' onkeyup="trans(this.id)" value='<? echo $answer; ?>'></input>
<button type='submit' name='action' value='answer'>Send</button>
<button type='submit' name='action' value='next'>Next</button>
<button type='submit' name='action' value='back'>Back</button>
<button type='submit' name='action' value='hint'>Get a hint.</button>
</form>
</div>
<?php
} <--------------- THis is the } it's not expecting....
?>
<?php
if ( $msg != "" ){ ?>
<script language='javascript'>
alert( "<?php echo $msg; ?>" );
</script>
<?php
}
?>
</body>
</html>

我已经在我的代码块末尾指出了违规行。

最佳答案

一台服务器可能不喜欢你的short open tags : <? .尝试用 <?php 替换它们.

关于php - 页面仅在 PHP 5.3.1 上显示语法错误,但在 5.2.6 上正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5289969/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com