What is PHP and why it is used?

  • The full name of PHP is Hypertext Preprocessor, but its old name was Personal Home Page.
  • PHP is a server side scripting language.
  • PHP is free, open source, loosely typed scripting language.
  • PHP is an Interpreted language.
  • PHP was developed by Rasmus Lerdorf in 1995.
  • PHP supports MYSQL database by default.
  • The extension of PHP file is .php.

Why we use PHP?

Easy to Learn: PHP's code is very simple. There are different ways to write PHP syntax, one of which is shown syntax.

//Your Code Here


Large Community: If you are writing PHP code, and there is an error in your code, then you can ask the PHP community. There are many experienced developers in this community. Which can easily solve your error.

Easy Hosting Setup: Almost every web hosting provider supports PHP. And you can easily host your website on any hosting service. Hosting a PHP website is very simple.

What are the features of PHP?

Dynamic Type: PHP is a dynamic type language, which means when the data type of a variable is decided at runtime. We call this loosely type language. In PHP, we do not have to define the data type of the variable.

Object Oriented: PHP supports the OOPs concept, so that we can make the code scalable and secure. This also increases the performance of the application and the code can also be reused.

Open Source: PHP is open source. You can configure PHP accordingly. Since PHP is open source, we do not need to pay any money to use it.

Platform Independent: PHP can be executed on any operating system. Because PHP is platform independent language.

What is comments in PHP?

Comments are the text that the compiler or interpreter ignores. But writing comments is very important. When you create a function, it is necessary to tell us what this function will work and what type of value it will return and we use comments to tell all this. The syntax of comments in php is as follows.

In PHP, we use # or double // symbol for single line comment, and  /* */ symbol for multi line comment.

//This is single line comment
/* This is multi line comment */

What is variable in PHP ?

Variable is the name of a memory location in which data is stored at run time. And we access that data only by the variable name.

Rules for declaring variables in PHP

  • All variable names must begin with a dollar ($) symbol.
  • Variable names in PHP are case-sensitive.
  • The variable name should not start with a number.
  • There should be no space in between the variable name.

What are Operators in PHP ?

An operator is a symbol that tells the interpreter to perform specific mathematical or logical manipulations. PHP supports the following operators.

  • Arithmetic Operator
  • Assignment Operator
  • Comparison Operator
  • Logical Operator
  • Bitwise Operator
  • String Operator
  • Increment/Decrement operators
  • Special Operators

What is Conditional Statement in PHP ?

Conditional statements are those statements where a hypothesis is followed by a conclusion. This is also known as an "if-else" statement. PHP supports the following conditional statements.

  • if statement
  • if else statement
  • switch

What are loops in PHP ?

A loop is a sequence of instructions that repeats continuously until a certain condition is reached. PHP supports the following loops statement.

  • For loop
  • while loop
  • do while loop
  • foreach loop

What are keywords in PHP ?

Keywords are predefined, reserved words that are used in programming that have a special meaning for the interpreter. PHP has many keywords and some predefined functions which you cannot use as variable name, function name, class name.

What is Array in PHP ?

An Array is a collection of items stored in contiguous memory location. With the help of array, we can assign values ​​of same data type to a single variable. But in PHP we can also store values ​​of different datatypes in an array.

To access the values ​​of the array, we use the index number, the index number starts from 0. PHP supports the following types of arrays.

  • Single dimensional array
  • Multi dimensional array
  • Associative Array

What is function in PHP ?

A function is an organized block of code that is used to perform a single task. By using function, we can increase the readability of the code and it also saves the code from being repeated. To create a function in PHP, we have to write the function keyword.

There are two types of function

  • User defined function
  • Built-in function


We have covered some important PHP questions. If you have any topic on which you want an article, you must tell it by email.