9

wp shell is a very useful tool that lets you run PHP statements and expressions interactively, from within a Wordpress environment. It lets you use all the functions, classes and globals that you can use within Wordpress.

Is there a similar tool that will let me run a PHP file?

1 Answer 1

10

Yes, there is! I didn't find it at first, but wp cli offers a command called eval-file which does what you want:

$ echo '<?php echo is_wp_error("foo") ? 1 : 0;' > example.php
$ wp eval-file example.php
0
2

Your Answer

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

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