I have a network of over a hundred sites and I try to use wp-cli to make bulk changes to many of these. Particularly to their wp_x_options table via wp --url=site.url option update

However, wp commands fail with several of my files, severely limiting the usefulness of the tool, particularly when trying to run with a list of urls | xargs wp --url={} ... because after the first failure, the rest are skipped.

The error I get is always the same:

PHP Parse error: syntax error, unexpected end of file in ... /functions.php

This error does not happen when loading the pages normally via the browser. My functions.php files are perfectly OK. Some of them don't have a closing ?> tag but that can't be the problem since many of these (lacking closing ?>) run OK with wp-cli.

Any thoughts?

WP-CLI 0.18.0 Wordpress 4.0.1 PHP 5.5.9-1ubuntu4.4 (cli) php.ini has error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT display_errors = Off


1 Answer 1


As noted in https://github.com/wp-cli/wp-cli/issues/1754#issuecomment-91361340, I figured this one out. It turns out it wasn't wp-cli's fault at all.

My confusion arose from the fact that I'm running a web server with nginx and php fpm, which has it's own php.ini . wp commands run php (cli) directly on the host and so the config can be different. In this case my php cli didn't allow short_open_tag (


Just enabled


in /etc/php5/cli/php.ini p.s. this is an aws ubuntu box

  • You would be better off to find the files in your system using short PHP tags and change them to not do that. Disabling short_open_tag everywhere is recommended for clarity. Short tags are bad practice due to portability, and additionally they don't adhere to the PHP basic coding standard PSR-1.
    – Otto
    Apr 9, 2015 at 22:48
  • Thanks, I'm aware but it's not obvious how to do that in thousands of files reliably without having to supervise the whole process, which is not my role :) Apr 10, 2015 at 23:14
  • Also the entire PHP version between webserver and cli can be different.
    – Andy
    Feb 11, 2019 at 19:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.