Thursday, 26 March 2020

Chapter 1: Introduction to PHP Programming Q & A (#ipumusings)(#php)

Chapter 1: Introduction to PHP Programming

Chapter 1: Introduction to PHP Programming Q & A (#ipumusings)(#php)

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
- sessions, 
- cookies,  
- web services, 
- cryptography etc.

Q5: What are new features introduced in PHP 7?

Answer
- 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
- Throwables
- 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 update
apt-get install -y software-properties-common
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get update
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.

Chapter 1: Introduction to PHP Programming Q & A (#ipumusings)(#php)

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?

Answer

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>My First PHP Page</title>
</head>
<body>
    <div>
        <h1>The Heading</h1>
        <p>
            <?php
            // your php code goes here 
            ?>
        </p>        
    </div>
</body>

<script>

// JavaScript code goes here

</script>
</html>


No comments:

Post a Comment