If you want to run/test oneliners in PHP on the command line you can use the -r option.
php -r 'echo "Hello World";'
Will simply output “Hello World” on the command line
I sometimes use this method to test regexp expressions
php -r 'echo preg_match("/^Test/", "This is a test");'
Here I check if $string starts with the string ‘Test’ (the answer is no).
Using onliners on the command line can sometimes be very handy
0 Comments.