0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

indeed: string(146) "PHP 4.4.9 (cgi) (built: Apr 20 2012 18:34:17) Copyright (c) 1997-2008 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies " Is the php cli version independant from the php version which is 5.5 on my server?
no, your server is running with PHP 4.4.9 and not with 5.5 as you said. are you the administrator of this server ? if yes : check if you have downloaded the right version of php, linking correctly your Apache server with your PHP and restarted your apache
Thanks your answer helped me a lot! No I'm not administrator, but apparently OVH runs by default two different versions for CLI and CGI!! I found that I have to call a newer version of php-cli by specifiying its entire path, now it works.
i am delighted to have helped you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.