PHP Interview Questions & Answers for Freshers

Are you a looking for PHP Interview Questions for Freshers? Find PHP Interview Questions and Answers for beginners here. It is important to learn basic PHP concepts while doing PHP Job Preparation. These are the commonly asked Interview questions for beginners.

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 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


    What is include() function in PHP?

    The include() takes all the content in a specified file and includes it in the current file.
    If an error occurs, the include() function generates a warning, but the script will continue execution.