Sr. PHP Programmer Interview Questions & Answers
Download PDF

Refine your Senior PHP Programmer interview skills with our 202 critical questions. Each question is crafted to challenge your understanding and proficiency in Senior PHP Programmer. Suitable for all skill levels, these questions are essential for effective preparation. Access the free PDF to get all 202 questions and give yourself the best chance of acing your Senior PHP Programmer interview. This resource is perfect for thorough preparation and confidence building.

202 Senior PHP Programmer Questions and Answers:

Senior PHP Programmer Job Interview Questions Table of Contents:

Senior PHP Programmer Job Interview Questions and Answers
Senior PHP Programmer Job Interview Questions and Answers

1 :: What is the purpose of continue statement?

continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

2 :: What is the purpose of _CLASS_ constant?

_CLASS_ − The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.

3 :: What is the purpose of _METHOD_ constant?

_METHOD_ − The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).

4 :: Can you assign the default values to a function parameters?

Yes! You can set a parameter to have a default value if the function's caller doesn't pass it.

5 :: What is associate array in PHP?

Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.

6 :: What are PHP magic constants?

PHP provides a large number of predefined constants to any script which it runs known as magic constants.

8 :: What do you mean by having PHP as whitespace insensitive?

Whitespace is the stuff you type that is typically invisible on the screen, including spaces, tabs, and carriage returns (end-of-line characters). PHP whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.

9 :: What is the purpse $_REQUEST variable?

The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE. We will discuss $_COOKIE variable when we will explain about cookies. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

10 :: What is the purpose of _LINE_ constant?

_LINE_ − The current line number of the file.

11 :: What is the purpose of $_FILES variable in PHP?

This is a global PHP variable. This variable is an associate double dimension array and keeps all the information related to uploaded file.

12 :: What is the purpose of php.ini file?

The PHP configuration file, php.ini, is the final and most immediate way to affect PHP's functionality. The php.ini file is read each time PHP is initialized.in other words, whenever httpd is restarted for the module version or with each script execution for the CGI version. If your change isn.t showing up, remember to stop and restart httpd. If it still isn.t showing up, use phpinfo() to check the path to php.ini.
To delete a cookie you should call setcookie() with the name argument only.

14 :: How will you open a file in readonly mode?

The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate. "r" mode opens the file for reading only and places the file pointer at the beginning of the file.

15 :: How will you start a session in PHP?

A PHP session is easily started by making a call to the session_start() function.This function first checks if a session is already started and if none is started then it starts one. It is recommended to put the call to session_start() at the beginning of the page.

16 :: How will you check if a file exists or not using php?

File's existence can be confirmed using file_exist() function which takes file name as an argument.

17 :: How will you generate random numbers using PHP?

The PHP rand() function is used to generate a random number. This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated. This is achieved using the srand() function that specifies the seed number as its argument.

18 :: How will you get information sent via post method in PHP?

The PHP provides $_POST associative array to access all the sent information using POST method.

19 :: How will you unset a single session variable?

Here is the example to unset a single variable −

<?php
unset($_SESSION['counter']);
?>

20 :: How will you get cookies using PHP?

PHP provides many ways to access cookies. Simplest way is to use either $_COOKIE or $HTTP_COOKIE_VARS variables.

21 :: How will you get information sent via get method in PHP?

The PHP provides $_GET associative array to access all the sent information using GET method.

22 :: What are the common usage of PHP?

Common uses of PHP −
☛ PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
☛ PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.
☛ You add, delete, modify elements within your database thru PHP.
☛ Access cookies variables and set cookies.
☛ Using PHP, you can restrict users to access some pages of your website.
☛ It can encrypt data.

23 :: How can you sort an array?

sort() − Sorts an array.

24 :: How will you set cookies using PHP?

PHP provided setcookie() function to set a cookie. This function requires upto six arguments and should be called before <html> tag. For each cookie this function has to be called separately.

setcookie(name, value, expire, path, domain, security);

25 :: How will you destroy the session?

A PHP session can be destroyed by session_destroy() function.
Senior PHP Programmer Interview Questions and Answers
202 Senior PHP Programmer Interview Questions and Answers