Chapter 1: Introduction to PHP Programming
Questions & Answers
Q1: What does PHP stands for?
Answer: Hypertext Preprocessor
PHP is a server side scripting solution that empoweres developers to build dynamic HTML pages.
Q2: Who is the original creator of PHP?
Answer: Rasmus Lerdorf developed PHP around 1995.
Q3: Does PHP support object oriented programming?
Answer: Yes it supports the object-oriented programming (OOP) paradigm.
Q4: What are the common web development features supported by PHP?
Answer: PHP supports many web development related features such as:
- file handing
- database support
- web services,
- cryptography etc.
Q5: What are new features introduced in PHP 7?
- Scalar type hints
- Return type hints
- Anonymous classes
- Generator delegation
- Generator return expressions
- The null coalesce operator
- The spaceship operator
- Constant arrays
- Uniform variable syntax
- Group use declarations
- Class constant visibility modifiers
- Catching multiple exceptions types
- Iterable pseudo-type
- Nullable types
- Void return types
Q6: How can one install PHP7 on Ubuntu 18 Linux?
Answer: One has to run following comands (one by one as superuser) in a terminal:
apt-get install -y software-properties-common
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get install -y php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql
Q7: Give examples of websites that are built using PHP.
Answer: Facebook, Wikipedia, and WordPress.
Q8: Is PHP server side scripting language or client side scripting?
Answer: PHP is a server-side scripting language.
Q9: What is PHP template engine?
Answer: To generate dynamic HTML content, PHP templates are used. One can embed PHP code in HTML using <?php ?> tags.
Any page intended to use PHP code has a .php file extension which tells the web server to invoke PHP processor.
Q10: How does web server builds PHP page dynamically?
Answer: The web server builds each PHP page dynamically in response to a request using the following sequence of events:
1. The browser sends a request to the web server.
2. The web server hands the request to the PHP engine, which is embedded in the server.
3. The PHP engine processes the code. In many cases, it might also query a database before building the page.
4. The server sends the completed page back to the browser.
Q11: Does PHP generate only HTML output?
Answer: Not necessarily. One can generate simple text, XML or JSON as output.
Q12: What does a simple php file look like?