Tag Archives: execute

Execute PHP code directly on command line

I always wondered if running PHP code directly in the command line could be posible and today, thanks to a tweet from Symfony creator Fabien Potencier, I learned how to do it. You just have to use the -r option of PHP:

$ php -r 'echo "Hello World!" . PHP_EOL;'
Hello World!