PHP Interview Questions for beginners - Webliquids

php interview questions answers 2 PHP Interview Questions

Are you preparing for the Interviews in PHP Development for the first time and nervous for the Interviews that what questions can be asked?

Don’t be Stressed!

Webliquids helps you for the preparations of the Top PHP Interview Questions in Web-Development. PHP is a significant part of the web world, and every web developer should have knowledge in PHP. Here we are mentioning the list of commonly asked PHP interview Questions and Answers that will help you to be prepared for the interviews for the profile of PHP Developer.

  1. What is PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is the widely used open source scripting language, majorly used for web development and application development and can be rooted into HTML.

  1. What is the meaning of Hypertext Preprocessor?

PHP earlier started as Personal Home Page tools, developed by Rasmus Lerdorf in 1995, and it further acquired the name “PHP Hypertext Preprocessor” which is the recursive backronym along the way to signify its expanded capabilities. PHP code can be simply mixed with HTML code, or it can be used in combination with numerous templating engines and web frameworks.

  1. Why is the PHP called Hypertext?

PHP is known as hypertext preprocessor as its libraries are already compiled. When a PHP page is retrieved, the PHP code is read or “parsed” by the server the page exists in on and the output from the PHP functions on the page is returned as HTML code, which can be read by the browser.

  1. How will you concatenate two strings?

To concatenate two string variables, dot(.) operator is used by two ways. The first is the concatenation operator (‘.’), which yields the concatenation of its right and left arguments. The second is the concatenating assignment operator (‘.=’), which affixes the argument on the right side to the argument on the left side:

<?php

$a = “Hello “;

$b = $a . “World!”; // now $b contains “Hello World!”

$a = “Hello “;

$a .= “World!”;     // now $a contains “Hello World!”

?>

5. Difference between the include() and require() functions?

They both include a specific file but on require the process exits with a fatal error if the file can’t be incorporated, while contain statement may still pass and jump to the next step in the implementation.

6.What are Traits?

Traits are a tool that permits you to create reusable code in languages like PHP where multiple inheritances is not supported. A Trait cannot be instantiated on its own.

  1. What is MVC?

The Model-View-Controller (MVC) is an architectural design that separates an application into three main logical components: the model, the view, and the controller.

Model: – Model resembles to the information in an application.

View: – View represents the pictorial representations of information and data that you have entered.

Controller: – Controller acts as an interface between Model and View components. It handles all the interfaces and inputs from the customer View and updates the database using the Customer Model.

  1. Difference between GET and POST?

– GET shows the submitted data as part of the URL, during POST this information is not shown as it’s encoded in the request.

– GET can handle 2048 characters, POST has no such limitations.

– GET permits only ASCII data, POST has no restrictions, binary data are also permitted.

– Normally GET is used to retrieve data while POST to insert and update.

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

We can include a file using “include() ” or “require()” function with a file path as its parameter.

  1. How to declare an array in PHP?

Eg :var $arr = array(‘apple’, ‘grape’, ‘lemon’);

php interview question answer 4

  1. What is the use of ‘print’ in php?

It is a language concept. So you can use it with or without parentheses with its argument tilt.

Example:

print(‘PHP Interview questions’);

print ‘Job Interview ‘;

  1. What is use of in_array() function in PHP?

In_array used to checks if a value exists in an array

  1. What is use of count() function in PHP?

count() is used to count all origins in an array or something in an object.

  1. What is the difference between Session and Cookie?

The main difference between sessions and cookies is that sessions are stored on the server, and cookies are stored on the user’s computers in the text file format. Cookies cannot grip multiple variables, But Session can hold multiple variables. We can set termination for a cookie, the session remains active as long as the browser is open. Users do not have admittance to the data you stored in the Session since it is stored in the server. Session is mainly used for login/logout resolve while cookies using for user activity tracking

  1. How to set cookies in PHP?

Setcookie(“sample”, “ram”, time()+3600);

How to Retrieve a Cookie Value?

Eg : echo $_COOKIE[“user”];

  1. How to create a session?

Create session :session_start();

  1. How to set a value in session ?

Set value into session : $_SESSION[‘USER_ID’]=1;

  1. How to Removedata from a session?

Remove data from a session : unset($_SESSION[‘USER_ID’];

  1. What types of loops exist in php?

for,while,do while and foreach (NB: You should learn its usage)

php interview question

  1. Write a program using while loop?

my_qry = mysql_query(“SELECT * FROM `users` WHERE `u_id`=’1′; “);

while($result = mysql_fetch_array($my_qry))

{

echo $result[‘First_name’.].”<br/>”;

}

PHP Interview Questions
You May Also Like  Interview questions for Graphic Designing
Call Now
Directions