草庐IT

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

coder 2024-04-22 原文

我有两台开发服务器,一台是 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/

有关php - 页面仅在 PHP 5.3.1 上显示语法错误,但在 5.2.6 上正常的更多相关文章

  1. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  2. ruby - 树顶语法无限循环 - 2

    我脑子里浮现出一些关于一种新编程语言的想法,所以我想我会尝试实现它。一位friend建议我尝试使用Treetop(Rubygem)来创建一个解析器。Treetop的文档很少,我以前从未做过这种事情。我的解析器表现得好像有一个无限循环,但没有堆栈跟踪;事实证明很难追踪到。有人可以指出入门级解析/AST指南的方向吗?我真的需要一些列出规则、常见用法等的东西来使用像Treetop这样的工具。我的语法分析器在GitHub上,以防有人希望帮助我改进它。class{initialize=lambda(name){receiver.name=name}greet=lambda{IO.puts("He

  3. ruby-on-rails - Rails 编辑表单不显示嵌套项 - 2

    我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib

  4. ruby - 解析 RDFa、微数据等的最佳方式是什么,使用统一的模式/词汇(例如 schema.org)存储和显示信息 - 2

    我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i

  5. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  6. ruby-on-rails - link_to 不显示任何 rails - 2

    我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article

  7. ruby-on-rails - 如何在 Rails View 上显示错误消息? - 2

    我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c

  8. ruby - 覆盖相似的方法,更短的语法 - 2

    在Ruby类中,我重写了三个方法,并且在每个方法中,我基本上做同样的事情:classExampleClassdefconfirmation_required?is_allowed&&superenddefpostpone_email_change?is_allowed&&superenddefreconfirmation_required?is_allowed&&superendend有更简洁的语法吗?如何缩短代码? 最佳答案 如何使用别名?classExampleClassdefconfirmation_required?is_a

  9. ruby-on-rails - 无法让 rspec、spork 和调试器正常运行 - 2

    GivenIamadumbprogrammerandIamusingrspecandIamusingsporkandIwanttodebug...mmm...let'ssaaay,aspecforPhone.那么,我应该把“require'ruby-debug'”行放在哪里,以便在phone_spec.rb的特定点停止处理?(我所要求的只是一个大而粗的箭头,即使是一个有挑战性的程序员也能看到:-3)我已经尝试了很多位置,除非我没有正确测试它们,否则会发生一些奇怪的事情:在spec_helper.rb中的以下位置:require'rubygems'require'spork'

  10. ruby 语法糖 : dealing with nils - 2

    可能已经问过了,但我找不到它。这里有2个常见的情况(对我来说,在编程Rails时......)用ruby​​编写是令人沮丧的:"astring".match(/abc(.+)abc/)[1]在这种情况下,我得到一个错误,因为字符串不匹配,因此在nil上调用[]运算符。我想找到的是比以下内容更好的替代方法:temp="astring".match(/abc(.+)abc/);temp.nil??nil:temp[1]简而言之,如果不匹配,则简单地返回nil而不会出错第二种情况是这样的:var=something.very.long.and.tedious.to.writevar=some

随机推荐