【问题标题】:Parse Error: Unexpected T_OBJECT_OPERATOR解析错误:意外的 T_OBJECT_OPERATOR
【发布时间】:2014-09-08 15:36:18
【问题描述】:

我在第 16 行收到以下解析错误:“语法错误,意外的 T_STRING”。话虽如此,下面的代码块在 PHP 5.4.16 中可以正确解析,但是在 PHP 4.4.9 中无法正确解析。想法?

对我来说,错误提示 PHP 4.4.9 不支持 interface 关键字,但是,我在 PHP 的更改日志中找不到。

interface iA { // line 16
  public function methodA();
  public function methodB();
  public function methodC();
}

编辑(提供完整的 sn-p)

<?php

// a comment.
// a comment.
// a comment.
// a comment.
// a comment.
// a comment.

// a comment.
if (!defined('PRODUCT_ENV')) {
  exit;
}

// a comment.
interface iA {
  public function methodA();
  public function methodB();
  public function methodC();
}

include(PRODUCT_PWD . PRODUCT_IMPLES . 'anotherfile.php');

【问题讨论】:

  • 是的,你需要 PHP 5。

标签: php parsing parse-error php-parse-error


【解决方案1】:

请查看 PHP 手册 Migrating from PHP 4 to PHP 5.0.x 章节的 New Object Model 部分。旧 PHP/4 对象模型的文档已移至 Classes and Objects (PHP 4) 附录。

PHP/5 是在 10 年前(2004 年 7 月)发布的,因此很难在任何地方找到对 PHP 4 的支持。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-23
    • 2013-07-28
    • 1970-01-01
    • 2017-03-08
    • 1970-01-01
    • 2013-12-28
    相关资源
    最近更新 更多