heidilabs / markov-php

experiments with markov chain in php
MIT License
16 stars 8 forks source link

Parse Error #3

Open fredowsley opened 7 years ago

fredowsley commented 7 years ago

Getting the following error when trying to run this:

$ php chainer.php demos/resources/mobydick.txt PHP Parse error: syntax error, unexpected '[' in /home/user/vendor/heidilabs/markov-php/src/MarkovPHP/WordChain.php on line 120

$ php -v PHP 5.3.10-1ubuntu3.26 with Suhosin-Patch (cli) (built: Feb 13 2017 20:37:53) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

bredmor commented 7 years ago

@fredowsley PHP 5.3 is an unsupported branch and will not run code written with many modern PHP features. It has been obsolete for 2 years and 7 months as of the time you posted this issue. As of the time of this reply, the supported release PHP branches are 5.6, 7.0 and 7.1.

You are encountering that error because PHP 5.3 does not support shorthand array syntax, which was added in PHP 5.4. If you cannot upgrade your version of PHP, you can replace the shorthand array syntax with the long form declaration of an empty array, but you will likely continue to encounter errors using such an old version of the interpreter.

fredowsley commented 7 years ago

Thank you for that detailed response! I have upgraded to a more recent version and it's working.