6

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?

5

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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