Search code examples
phpcmdincludecommand-line-interfaceparse-error

PHP include error when calling script from CLI


I'm trying to call from CLI a php script that include the PHP Simple HTML DOM Parser library, I've two files:

File test.php

<?php
echo exec('php -f script.php');
?>

File script.php

<?php
include('simple_html_dom.php');
$ob = new simple_html_dom();
?>

On PHP 5.5.12 this works perfectly, but on a server that runs PHP 5.5.18 I got the following error:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /path/to/simple_html_dom.php on line 117

Line 117 is:

public $nodetype = HDOM_TYPE_TEXT;

This constante is declared in line 48 as:

define('HDOM_TYPE_TEXT',    3);

I see no problem! I don't know why it's bugging in .18 and not in .12, I've tried everything, can you help me?


Solution

  • I think that your server is running with very old version of PHP
    try this : var_dump(shell_exec("php --version")); or simply run phpinfo.php