Top PHP interview Questions for freshers with answers
In this article, we’ve provided selected PHP interview questions and answers for freshers WHO are going to appear for employment interview as a PHP developer. These PHP interview questions are picked for you to help you in the preparations of your interview for PHP Programming Language.
It will assist you to prepare for technical interviews and on-line tests conducted throughout placement process for freshers and job interviews for professionals. I hope you get these PHP interview questions and answers useful and it will assist you to expand your basic PHP skills.
Why must you read this article?
This article includes basic questions which are mostly asked in fresher interviews.
To help you prepare for required technical PHP Interview Questions and answers in 2018
Let’s have a look at significant PHP Interview Questions and Answers for freshers.
1. What is PHP?
PHP is recursive acronym for Hypertext Processor and is a widely used open source general-purpose scripting language that is executed on server and can be embedded into HTML very easily. Read more
2. What do the initials of PHP stand for?
PHP Stands for “Hypertext Preprocessor“
3. How do you display the output directly to the browser?
I will use the special tags to display the output directly to the browser.
<?= and ?>
4. Which programming language does PHP resembles with?
Syntax of PHP resembles Perl and C.
5. How can you replace multiple if-else statements?
In place of multiple if-else statements I can use switch statement.
6. How will you execute a PHP script from the command line?
To execute a PHP script from the command line, use the PHP command line interface (CLI) and mention the file name of the script to be executed followed by term php as follows:
php script.php
7. What are the correct and the most two usual ways to start and finish a PHP code block?
The two most common methods to start and finish a PHP script are:
<?php /* my PHP code here */ ?> and <? /* my PHP code here */ ?>
8. Does PHP support multiple inheritance?
No. PHP supports only single inheritance, that means a class can be extended from only one single class using the keyword ‘extends‘.
9. How can you make PHP and HTML interact?
We can easily generate HTML using PHP scripts or we can embed HTML in PHP and vise versa, and it is also possible to pass information from HTML to PHP.
10. What is needed to be able to use image function?
GD library is required to execute image functions in PHP.
11. What is the use of the function gettype()?
gettype() is a PHP function that returns the data type of the variable value passed as argument.
12. What is PEAR?
PEAR is a framework and distribution system for reusable PHP components.PEAR is short for PHP Extension and Application Repository.
13. What is the main difference between require () and require_once ()?
require() includes and processes a specific file, while require_once() does that only if it has not been included before on the same page. So, require_once() is recommended to use there is a requirement to include a file only once.
14. WHAT is the limitation of GET method?
The GET method is restricted to send up to 1024 characters only.
15. How many data types does PHP supports?
PHP supports the following data types:
- String
- Integer
- Float (floating point numbers – also called double)
- Boolean
- Array
- Object
- NULL
- Resource
16. What is the use of “ksort” in PHP?
In PHP, ksort is used to sort an array by key in reverse order.
17. What is the use of Constant Function on PHP?
The constant() function returns the value of a constant.
18. Can a function name start with a number?
No, a function name in PHP can start with a letter or underscore but not with a number.
19. What is the difference between echo and echo() ?
The echo statement can be used with or without parentheses: echo or echo(). Hence there is no difference.
20. What is the use of glob function?
The glob() function returns an array of filenames or directories matching a specified pattern.