December 2, 2021

PHP tricks

Run webserver in current directory; great for trying a website quickly:

$ php -S localhost:8080
# now, open http://localhost:8080 in browser

Evaluate PHP code on command-line; great for trying stuff in PHP quickly:

$ php -r 'echo "Hello, World\n";'
Hello, World

Start interactive PHP shell; also great for trying stuff in PHP quickly:

$ php -a
php > echo 'Hello, World\n';
Hello, World\nphp>
// notice that linebreak is ignored...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.