PHP Interview Questions

Top 50 PHP Interview Questions

Hey all,

Being from an IT background myself, I have always been keen to learn about PHP development. I know you do too, that is why you are probably reading my blog!

So, collected from my personal experience of attending ample number of PHP interviews, I have devised a list of PHP Interview Questions including almost every question I have faced while my interview session. I will also help you with properly framed answers to each question to improve the way you are preparing for your interview. Let's begin!

1. What does the initials of PHP Stands for?

PHP means PHP: Hypertext PreProcessor that previously stood for personal home pages.


2. Who is the father of PHP?

Rasmus Lerdorf


3. The basic question that can come under both simple to advanced php interview questions is "what do you mean by PHP"?

PHP is an open source server-side scripting language that allows creating web pages dynamically and is used for web applications and can be embedded into HTML code.

To access PHP Scripts, only a web browser is required by client computer. PHP can also be used in combination with various web content management systems, web template systems, and web frameworks.


4. Which programming language does PHP resemble?

PHP syntax bears resemblance with PERL and C.


5. What PHP version is extensively used currently ?

Version 7.1 / 7.2


6. What do you mean when you say PHP is Open-Source?

Open-Source Software refers to the software that is dispersed with source code, can be freely used, read, modified and shared by anyone.

PHP is an Open-Source Software (OSS) as it meets the following benchmarks:

a) Source code of PHP is included with the program and is distributed freely.

b) Modified versions of source code for PHP are also redistributed.

c) Users are able to modify the distributed PHP source code.


7. How can we submit a form without a submit button?

JavaScript submit() function can be used to submit form without submit button on click call document.formname.submit ().


8. How can we create a database using PHP and MySQL?

We require a database before saving or accessing any data and to create any database in MySQL, CREATE DATABASE Statement is used.

e.g. mysql_create_db("Database Name")

read more


9. How to include a file to a PHP page?

It is possible to include one PHP file's content to other PHP file. The two functions "include()" and "require()" with file path as its parameter can be used to include a file.


10. What is role of Ksort() in PHP?

Ksort() is an inbuilt PHP function which is used to sort an associative array key in ascending order of its key values. For example:

$age=array("Jai"=>"59", "Dolly"=>"43", "Mack"=>"49", "Sam"=>"46");

ksort($age);


foreach ($age as $a => $b)

{

echo "$a = $b\n";

}

?>

Output:

Dolly = 43 Jai = 59 Mack = 49 Sam = 46


11. How to get the value of current session id?

session_id() function can be used to return the session id.


12. What are the functions of header () function in PHP?

This function is used for sending raw HTTP header to the client, and redirection of pages. It is very important to remark, that header() must be called before real output is seen, either by blank lines in a file, or from PHP or HTML tags.


13. Are multiple inheritances supported in PHP?

PHP includes only single inheritance. A Class can be extended from only one class and keyword used is 'extended'.


14. How can we execute a PHP script using command line?

We just need to run the PHP command line interface program and add the PHP Script file as the Command line argument

echo "Test";

echo "\n";

?>

Following are the four steps and paths that can be used to execute PHP in command line.

1. First login to your windows system.

2. Press windows and R key of keyboard simultaneously to open command prompt.

3. To find PHP executable file, move across PHP directory.

4. Executable file is accessed and then Path to PHP File.

The path with Change directory command used is C:\wamp\bin\php\php5.3.13. For Wamp Web Server users: php.exe path-to-your-php-file. If you visualize PHP version info, you can use PHP path-to-your-php-file instead of that command.


15. How can PHP and HTML Interact?

It is possible to generate HTML through PHP scripts and it is possible to pass information from HTML to PHP.

Read Full article:https://www.codingtag.com/top-50-php-interview-questions