Reputation: 22018
I have been using the clone keyword to duplicate objects like so:
$x = clone $obj;
as per the manual.
This works fine when accessed by browser. phpinfo()
reports PHP version 5.2.6.
However when run by cron or from the CLI I get
"Parse error: syntax error, unexpected T_VARIABLE"
from the clone keyword.
php -v
reports PHP 4.4.9 (cli)
Is this error from a version conflict?
If I use clone()
in my scripts like so:
$_SESSION['user'] = clone($userObject);
I get odd intermittent problems with the $_SESSION['user']
which do not occur when using the clone keyword.
Does this make any sense to anyone?
Any advice?
Upvotes: 0
Views: 521
Reputation: 22018
Turns out the server has 4 and 5 installed and the CLI reports 4.4.9 simply due to PATH order:
From support:
"Running the "php -v" command in the shell will always return V4. That's because we have two separate installs for PHP on your server. One for V4 and one for V5, and the PHP 4 interpreter shows up in your PATH environment variable first. If you'd like to use V5 through the shell you'll need to be sure to use the full path"
Upvotes: 1
Reputation: 16572
It seems that the clone $foo
keyword is only available on PHP 5 and newer.
Also, if you're still using PHP 4.4.9, that may be a bigger problem.
Upvotes: 3