New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Parse error: syntax error, unexpected '?' in phar:///usr/sbin/wp/php/WP_CLI/Runner.php #71

Closed
amys94fr opened this Issue Feb 19, 2018 · 4 comments

Comments

3 participants
@amys94fr

amys94fr commented Feb 19, 2018

Hi wp-cli Team,
I got this error when I use search-replace command
wp --allow-root search-replace 'http://mywebsite.com' 'https://mywebsite.com' --recurse-objects

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

@gitlost

This comment has been minimized.

Contributor

gitlost commented Feb 19, 2018

This probably means the initial <?php isn't getting stripped from your wp-config.php due to initial non-visible characters, probably a Unicode BOM. As mentioned in wp-cli/wp-cli#4661 (comment) could you do

hexdump -C wp-config.php | head -1

and if you see

ef bb bf 3c 3f 70 68 70  0a 2f 2a 2a 0a 20 2a 20  |...<?php./**. * |

then remove the BOM (ef bb bf) from your wp-config.php using your favourite (hex) editor.

(This situation will be dealt with by WP-CLI in a future release.)

@amys94fr

This comment has been minimized.

amys94fr commented Feb 20, 2018

Thanks you
I run this command to remove the BOM and now it works
sed -i '1s/^\xEF\xBB\xBF//' wp-config.php

@amys94fr amys94fr closed this Feb 20, 2018

@gitlost

This comment has been minimized.

Contributor

gitlost commented Feb 20, 2018

Thanks for the feedback @amys94fr . Using sed is a nice solution. This issue should be added the https://make.wordpress.org/cli/handbook/common-issues/ I think, so will use it there.

@h3nr1ke

This comment has been minimized.

h3nr1ke commented Oct 21, 2018

Thanks, it solved the problem here... =)
used this to check
hexdump -C wp-config.php | head -1

floowed by

sed -i '1s/^\xEF\xBB\xBF//' wp-config.php

to correct the file...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment