Fix PHP Parse error: syntax error, unexpected ‘?’ in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(941) : eval()’d code on line 1

If you like my WordPress work, check out my new plugin, Bylines. Thanks!

Are you seeing this PHP parse error when trying to use WP-CLI?

PHP Parse error: syntax error, unexpected '?' in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(941) : eval()'d code on line 1

You may have a Byte Order Mark at the beginning of your wp-config.php file.

Run head -n3 wp-config.php | hexdump -C to see if there’s a ef bb bf pattern at the beginning of the file:

$ head -n3 wp-config.php | hexdump -C
00000000  ef bb bf 3c 3f 70 68 70  0d 0a 0a 0a              |...<?php....|
0000000c

The Byte Order Mark can be removed with vim:

$ vim wp-config.php
:set nobomb
:wq