0

I was following this tutorial for creating a cms platform (https://www.elated.com/articles/cms-in-an-afternoon-php-mysql/#step6). I work on a mac, so I already had apache and php. I got the server running, but got the error

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

So I thought I'd try XAMPP to see if it was something I had done wrong when setting everything up, but I got the exact same error.

Any ideas? The repo is here https://github.com/liviarett/cms-platform

Article.php starts with

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

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

I don't think there's anything wrong with the code, since I copied and pasted it from the tutorial's instructions.

Livia Rett
  • 47
  • 1
  • 10

2 Answers2

0

You probably have a letter or any symbol in the lines before your class keyword.

check your code again or add a snapshot of your code so i can help you.

0

i don't there's something wrong with the code, i have copied the exact same code from your repo in github and nothing went wrong, here's a screenshot:

https://i.stack.imgur.com/jpCHu.jpg

azjezz
  • 3,827
  • 1
  • 14
  • 35
  • I don't think so either, I copied and pasted it from the tutorial, and no one else seems to be having this issue.. – Livia Rett Jan 14 '18 at 13:04
  • Seems you did not copy it correctly. I have raised a PR with the file updated. – Valerian Pereira Jan 14 '18 at 14:19
  • Hi @ValerianPereira, thanks for these, it seems that my editor added these spaces! That error is gone, but now I'm getting a 'Sorry, a problem occurred. Please try later.' Do you have any quick ideas why this is happening? – Livia Rett Jan 14 '18 at 14:48
  • Check what the exception message has to say. Config file ``` function handleException( $exception ) { echo "Sorry, a problem occurred. Please try later."; error_log( $exception->getMessage() ); } @LiviaRett – Valerian Pereira Jan 15 '18 at 03:25