gpt4 book ai didi

php - Apache 抛出 "Parse error: syntax error, unexpected ' 类'”

转载 作者:行者123 更新时间:2023-11-29 18:02:11 25 4
gpt4 key购买 nike

我正在按照本教程创建 cms 平台 ( https://www.elated.com/articles/cms-in-an-afternoon-php-mysql/#step6 )。我在 Mac 上工作,所以我已经有了 apachephp。我让服务器运行,但出现错误

Parse error: syntax error, unexpected 'class' (T_CLASS) in /Users/liviarett/Documents/projects/cms-project/classes/Article.php on line 7.

所以我想我应该尝试XAMPP看看这是否是我在设置所有内容时做错的事情,但我得到了完全相同的错误。

有什么想法吗? repo 协议(protocol)在这里 https://github.com/liviarett/cms-platform

Article.php 以

开头
<?php
 
/**
 * Class to handle articles
 */

class Article {
 
  // Properties
 
  /**
  * @var int The article ID from the database
  */
  public $id = null;
 

我认为代码没有任何问题,因为我是从教程的说明中复制并粘贴它的。

最佳答案

class 关键字之前的行中可能有一个字母或任何符号。

再次检查您的代码或添加代码快照,以便我可以帮助您。

关于php - Apache 抛出 "Parse error: syntax error, unexpected ' 类'”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48249623/

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