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.
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:
- Using standard tags: <?php PHP Code here ?>
- Using short tags: <? PHP Code here ?>
Example 1:
1 2 3 |
<?php echo "I love PHP"; ?> |
Example 2:
1 2 3 |
<? echo "I love PHP"; ?> |
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:
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 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:
- Integers: are whole numbers, without a decimal point, like 2567
- Doubles: are floating-point numbers, like 1.5 or 134.153
- Booleans: have only two possible values either true or false
- NULL: is a special type that only has one value: NULL
- Strings: is a sequence of characters, like “Hello PHP!”
- Arrays: stores multiple values in one single variable
- Objects: instances of user-defined classes
- 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:
1 2 3 4 5 6 7 8 |
<?php function greetings() { echo "Hello"; } greetings(); ?> |
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.
1 |
<form action="welcome.php" method="post"> |
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