All PHP Interview Questions & Answers

All PHP Interview Questions & Answers list

Here, you can find PHP Interview Questions & Answers related to Arrays, Operators, Loops, Variables, Conditional Statements, Strings, Form, MySQL, Cookies, and Sessions. These popular & frequently asked interview questions are listed under different categories.

Tutorials Class covers Interview Questions for Freshers as well as Experienced professionals. We not only list core PHP but also provide Advanced PHP interview questions for students.

What is PHP?

PHP stands for PHP: Hypertext Preprocessor. PHP is the most popular open-source programming language for web development. It is a server-side language which collects form data, send or retrieve cookies, interact with the database and much more. With the help of PHP, we can create static as well as dynamic websites.


Who is the father of PHP?

Rasmus Lerdorf is the father of the PHP who created PHP language in 1994.


What are the correct & common way to start and finish a PHP block of code?

The two most common ways to start and finish a PHP script are:

  1. Using standard tags: <?php PHP Code here ?>
  2. Using short tags: <? PHP Code here ?>

Example 1:

Example 2:


What is Open Source Software?

Open source software is one type of software on which the original source code is made freely available to the public. This software can also be redistributed and modified by the public.

Examples:
PHP, MySQL and WordPress are few examples of popular Open Source Software.


Is PHP a case sensitive language?

In PHP, Variable names are case-sensitive but function names are not case sensitive.

Explanation:

  • If you defined variable in lowercase, then you need to use it in lowercase everywhere in program. If we define a variable $name = "James"; then we must need to use $name. $NAME will not work
  • If you defined function name in lowercase, but calling them in uppercase it will work. For example, If we define function sum() {} then calling SUM() will also work.
  • Note: Function names are case-insensitive, though it is usually good form to call functions in the same case as they appear in their declaration.


    What is the default extension of PHP file?

    .php is the default extension of PHP file.


    What are the different data types in PHP?

    PHP data type is an attribute that tells about the type of data needs to be stored. There are 8 data types in PHP:

    1. Integers: are whole numbers, without a decimal point, like 2567
    2. Doubles: are floating-point numbers, like 1.5 or 134.153
    3. Booleans: have only two possible values either true or false
    4. NULL: is a special type that only has one value: NULL
    5. Strings: is a sequence of characters, like “Hello PHP!”
    6. Arrays: stores multiple values in one single variable
    7. Objects: instances of user-defined classes
    8. Resources: are special variables that hold references to resources such as database call

    What is PHP Function?

    PHP Function is a set of statements that perform a specific task. A function usually takes input arguments, perform a specific action on them and returns the result.


    Example of function in PHP:


    What are the form method Attribute available for submitting?

    The method attribute specifies how to send form-data. “GET” and “POST” are two methods to send form data to another page.


    What are the different PHP functions to sort an array?

    • asort()
    • arsort()
    • ksort()
    • krsort()
    • uksort()
    • sort()
    • nasort()
    • rsort()

    For more details: http://tutorialsclass.com/learn/php/php-array-functions