Chapter 2: Introduction to PHP Programming and PHP Variables
(Questions and Answers)
Q1: What are the two ways PHP can be used?
1. By using PHP templating engine which allows PHP code to output its content alongside HTML content.
2. Use PHP in the Interactive Shell which is the most common way PHP scripts are executed on a server.
Q2: Give an example to show PHP is used in interactive mode.
1. Open command shell (in Windows) or Bash shell in Linux.
2. Go to bin folder where PHP is installed.
3. Run php -a. It opens PHP as an interactive shell. php> command prompt appears.
4. Type echo "Hello World". It displays the string.
5. Type exit to quit interactive shell.
Q3: Give an example to run a PHP script at the command prompt?