8

How to install PHP Compiler/Interpreter on ubuntu 11.04

I have latest version of PHP, but I want to learn PHP from terminal. Is there a PHP interpreter available that will run PHP programs inside terminal.

e.g. I want to run command like "phpc" or "phpi" or "php" to open up PHP REPL.

Thanks.

2 Answers 2

12

Just run

sudo apt-get install php5-cli

To run it in interactive mode:

php -a

Run a file:

php /path/to/file
2
  • and how to run the compiler/interpreter ? using command php ? Jan 21, 2012 at 18:05
  • When I try that first command, I get a message: "E: Package 'php5-cli' has no installation candidate" Nov 7, 2016 at 8:04
3

Run the interpreter (there's no compiler in default PHP) using the "php" command, yes. If you'd like to know where "php" comes from (what executable is launched), type

which php

This is likely to give you "/usr/bin/php" as an answer, unless you have a special setup.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .