Php command line

Using Python I can test my code in the terminal / command line by typing

python 
python> print "hello world"

I would also like to do this with PHP, but on input:

php
echo "hello world";

he does not work. Is it possible? what should I do? A quick search on the Internet gives a lot of results that cause the actual .php file to run. I want to check only one sentence, if possible, without creating files, etc.

+5
source share
3 answers

Try

php -a

PHP. , , PHP - -readline ( , PHP Mac OS X, .).

, ,

php -r 'print_r(get_defined_constants());'

PHP ( readline).

+7
php -r "echo 'hello world';"
+1

If you run phpwithout an option -a, do not forget <?phpat the beginning

+1
source

All Articles