PHP Interview Questions And Answers For 5 Year Experience

PHP Interview Questions And Answers For 5 Year Experience. Here in this blog post Coding compiler presenting a list of 50 PHP experience interview questions and advanced PHP interview questions for 5 years experienced developers. We hope that these senior PHP interview questions will help you to crack your next PHP job interview. All the best for your future and happy learning.

PHP Experience Interview Questions

  1. How can we know the number of days between two given dates using PHP?
  2. How can we repair a MySQL table?
  3. How can we get the properties of an image (size, type, width, height) using php image functions?
  4. How can we take a backup of a mysql table and how can we restore it?
  5. What is a persistent cookie and how it is different from the Temporary cookie?
  6. How To Get the Uploaded File Information in the Receiving Script?
  7. What is the difference between mysql_fetch_object and mysql_fetch_array?
  8. What are the different tables present in MySQL?
  9. How can we encrypt the username and password using PHP?
  10. How can we send mail using JavaScript?
  11. What is the difference between ereg_replace() and eregi_replace()?
  12. How do I find out the number of parameters passed into a function?
  13. What’s the special meaning of __sleep and __wakeup?
  14. What is the difference between the functions unlink() and unset()?
  15. What is the difference between characters \023 and \x23?
  16. What’s the output of the ucwords function in this example?
  17. What’s the difference between htmlentities() and htmlspecialchars()?
  18. What are the different functions in sorting an array?
  19. How can we know the count/number of elements of an array?
  20. What is the maximum length of a table name, a database name, or a field name in MySQL?

Must Read PHP Interview Questions Books

PHP Interview Questions And Answers For 5 Year Experience

1) How can we know the number of days between two given dates using PHP?

A) Simple arithmetic:

$date1 = date(‘Y-m-d’);
$date2 = ‘2006-07-01’;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo “Number of days since ‘2006-07-01’: $days”;

2) How can we repair a MySQL table?

A) We can use REPAIR command to repair a table. The REPAIR command will repair the table specified.

The syntex for repairing a mysql table is:
REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED

If QUICK is given, MySQL will do a repair of only the index tree.
If EXTENDED is given, it will create index row by row.

3) How can we get the properties of an image (size, type, width, height) using php image functions?

A) To know the Image type use exif_imagetype () function
To know the Image size use getimagesize () function
To know the image width use imagesx () function
To know the image height use imagesy() function

4) How can we take a backup of a mysql table and how can we restore it?

A) Create a full backup of your database:

shell> mysqldump tab=/path/to/some/diropt db_name

Or

shell> mysqlhotcopy db_name /path/to/some/dir

The full backup file is just a set of SQL statements, so restoring it is very easy:

shell> mysql “.”Executed”;
mysql_close($link2);

5) What Is a Persistent Cookie and how it is different from Temporary cookie?

A) A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:

  • Temporary cookies cannot be used for tracking long-term information.
  • Persistent cookies can be used for tracking long-term information.
  • Temporary cookies are safer because no programs other than the browser can access them.
  • Persistent cookies are less secure because users can open cookie files see the cookie values.

Read This Article: UI Developer Interview Questions

6) How To Get the Uploaded File Information in the Receiving Script?

A) Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:

  • $_FILES[$fieldName][‘name’] – The Original file name on the browser system.
  • $_FILES[$fieldName][‘type’] – The file type determined by the browser.
  • $_FILES[$fieldName][‘size’] – The Number of bytes of the file content.
  • $_FILES[$fieldName][‘tmp_name’] – The temporary filename of the file in which

The uploaded file was stored on the server.

  • $_FILES[$fieldName][‘error’] – The error code associated with this file upload.

The $fieldName is the name used in the <input name=”fieldName” type=”FILE,” />

7) What is the difference between mysql_fetch_object and mysql_fetch_array?

A) MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array

8) 14. What are the different tables present in MySQL?

A) Total 5 types of tables we can create

  1. MyISAM
  2. Heap
  3. Merge
  4. INNO DB
  5. ISAM

9) How can we encrypt the username and password using PHP?

A) You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(“Password”);

Or

You can use the MySQL PASSWORD() function to encrypt username and password.

Example: INSERT into user (password, …) VALUES (PASSWORD($password”)), …);

10) How can we send mail using JavaScript?

A) No. There is no way to send emails directly using JavaScript.

But you can use JavaScript to execute a client side email program send the email using the “mailto” code.

Here is an example:

function myfunction(form)
{
tdata=document.myform.tbox1.value;
location=”mailto:[email protected]?subject=…”;
return true;
}

PHP Developer Interview Questions And Answers For Experienced

PHP Interview Questions And Answers For 5 Year Experience
11) What is the difference between ereg_replace() and eregi_replace()?

A) eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.

12) How do I find out the number of parameters passed into function?

A) func_num_args() function returns the number of parameters passed in.

Also Read: AngularJS Interview Questions

13) What’s the special meaning of __sleep and __wakeup?

A) __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

14) What is the difference between the functions unlink() and unset()?

A) unlink() is a function for file system handling. It will simply delete the file in context.

unset() is a function for variable management. It will make a variable undefined.

Interview Questions For PHP Developer

15) What is the difference between characters \023 and \x23?

A) The first one is octal 23, the second is hex 23.

PHP Interview Questions And Answers For 5 Year Experience
16) What’s the output of the ucwords function in this example?

$formatted = ucwords(“PHP interview questions for experienced”);
print $formatted;

A) ucwords() makes every first letter of every word capital.

What will be printed is PHP Interview Questions For Experienced.

17) What’s the difference between htmlentities() and htmlspecialchars()?

A) htmlspecialchars only takes care of <, >, single quote ‘, double quote ” and ampersand.

htmlentities translates all occurrences of character sequences that have different meaning in HTML.

18) What are the different functions in sorting an array?

A) Sorting functions in PHP:

  1. asort()
  2. arsort()
  3. ksort()
  4. krsort()
  5. uksort()
  6. sort()
  7. natsort()
  8. rsort()

19) How can we know the count/number of elements of an array?

A) In two ways, we can count the number of elements of an array:
a) sizeof($array) – This function is an alias of count()
b) count($urarray) – This function returns the number of elements in an array.

20) What is the maximum length of a table name, a database name, or a field name in MySQL?

A) The maximum length of a table name, database name and field name is:

Database name: 64 characters
Table name: 64 characters
Column name: 64 characters

PHP Mysql Interview Questions And Answers For 5 Years Experience

21) How many values can the SET function of MySQL take?

A) MySQL SET function can take zero or more values, but at the maximum it can take 64 values.

22) What are the other commands to know the structure of a table using MySQL commands except EXPLAIN command?

A) DESCRIBE table_name;

23) What’s the difference between md5(), crc32() and sha1() crypto on PHP?

A) The major difference is the length of the hash generated.

CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value.

This is important when avoiding collisions.

PHP Interview Questions And Answers For 5 Year Experience
24) How can we find the number of rows in a result set using PHP?

A) Here is how you can find the number of rows in a result set in PHP:

$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo “$num_rows rows found”;

25) How many ways we can we find the current date using MySQL?

A) We can find current date using MySQL in different ways, they are:

  • SELECT CURDATE();
  • SELECT CURRENT_DATE();
  • SELECT CURTIME();
  • SELECT CURRENT_TIME();

PHP Interview Quesetions And Answers For Senior Developers

26) How to read and display a HTML source from the website url?

A) $filename=”https://codingcompiler.com/”;
$fh=fopen(“$filename”, “r”);
while( !feof($fh) ){
$contents=htmlspecialchars(fgets($fh, 1024));
print “$contents”;
}
fclose($fh);
?>

PHP Interview Questions And Answers For 5 Year Experience
27) How we used $_get and $_post variable in PHP?

A) We know that when we use $_GET variable all data_values are display on our URL.So,using this we don’t have to send secret data (Like:password, account code). But using we can bookmarked the importpage.

We use $_POST variable when we want to send data_values without display on URL.And their is no limit to send particular amount of character.
Using this we can not bookmarked the page.

28) Why we use $_REQUEST variable?

A) We use $_REQUEST variable in PHP to collect the data_values from $_GET,$_POST and $_COOKIE variable.

29) How we use ceil() and floor() function in PHP?

A) ceil() is use to find nearest maximum values of passing value.

Ceil Example:
$var=6.5;
$ans_var=ceil($var);
echo $ans_var;

Output: 7

floor() is use to find nearest minimum values of passing value.

Floor Example:
$var=6.5
$ans_var=floor($var);
echo $ans_var;

Output: 6

PHP Interview Questions And Answers For 5 Year Experience
30) What is the answer of following code echo 1< 2 and echo 1 >2 ?

A) Output of the given code are given below:
echo 1<2
output: 1

echo 1>2
output: no output

PHP Programming Interview Questions And Answers For Experienced

31) What is the difference b/w isset and empty?

A) The main difference b/w isset and empty are:

isset: This variable is used to handle functions and checked a variable is set even through it is empty.

empty: This variable is used to handle functions and checked either variable has a value or it is an empty string,zero0 or not set at all.

PHP Interview Questions And Answers For 5 Year Experience
32) What do you understand about PHP accelerator ?

A) Basically PHP accelerator is used to boost up the performance of PHP programing language.We use PHP accelerator to reduce the server load and also use to enhance the performance of PHP code near about 2-10 times.In one word we can say that PHP accelertator is code optimization technique.

filetype:pdf
filetype:doc
filetype:txt

33) What is the functionality of MD5 function in PHP?

A) string md5(string)

It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number.

34) How can we know the number of days between two given dates using MySQL?

A) Use DATEDIFF()
SELECT DATEDIFF(NOW(),’2006-07-01′);

PHP Interview Questions And Answers For 5 Year Experience
35) How can we change the data type of a column of a table?

A) ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type]

PHP Experienced Interview Questions And Answers

36) How can we encrypt and decrypt a data presented in a table using MySQL?

A) You can use functions: AES_ENCRYPT() and AES_DECRYPT() like:
AES_ENCRYPT(str, key_str)
AES_DECRYPT(crypt_str, key_str)

37) How can I retrieve values from one database server and store them in other database server using PHP?

A) For this purpose, you can first read the data from one server into session variables. Then connect to other server and simply insert the data into the database.

PHP Interview Questions And Answers For 5 Year Experience
38) What are encryption functions in PHP?

A) CRYPT() and MD5()

39) How can we get second of the current time using date function?

A) $second = date(“s”);

40) How many ways we can give the output to a browser?

A) HTML output
PHP, ASP, JSP, Servlet Function
Script Language output Function
Different Type of embedded Package to output to a browser

PHP 5 Years Experience Interview Questions

41) How array_walk function works in PHP?

A) It is used to update the elements/index of an original array.
In array_walk, two parameter are required.
original array and an callback function, with use of we update the array.

PHP Interview Questions And Answers For 5 Year Experience
42) How to get the 2nd highest salary of an employee, if two employees may have the same salary?

A) select salary from employee group by salary order by salary limit 1,1

43) How to find duplicate email records in users table?

A) SELECT u1.first_name, u1.last_name, u1.email FROM users as u1
INNER JOIN (
SELECT email FROM users GROUP BY email HAVING count(id) > 1
) u2 ON u1.email = u2.email;

44) How to set the header in CURL?

A) curl_setopt($ch, CURLOPT_HTTPHEADER, Array(“Content-Type: text/xml”));

PHP Interview Questions And Answers For 5 Year Experience
45) How to redirect https to HTTP URL and vice versa in .htaccess?

A) Redirect https to http

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Redirect http to https

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

PHP Logical Interview Questions And Answers

46) What is the use of explode() function ?

A) This function is used to split a string into an array. Syntax : array explode( string $delimiter , string $string [, int $limit ] );

47) What is the use of mysql_real_escape_string() function?

A) mysql_real_escape_string() function mainly used to escapes special characters in a string for use in an SQL statement

PHP Interview Questions And Answers For 5 Year Experience
48) What are Traits?

A) Traits are a mechanism that allows you to create reusable code in PHP where multiple inheritance is not supported. To create a Traits we use keyword trait.

49) Can you write source code to demonstrate Traits?

A) Example of Traits

trait users {
function getUserType() { }
function getUserDescription() { }
function getUserDelete() { }
}

class ezcReflectionMethod extends ReflectionMethod {
use users;
}

class ezcReflectionFunction extends ReflectionFunction {
use users;
}

PHP Interview Questions And Answers For 5 Year Experience
50) How to start displaying errors in PHP application?

A) Add following code in PHP.

ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);

OR Add following code in .htacess

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on

Sources: Real Time Interview Questions  |  PHP My Passion

RELATED INTERVIEW QUESTIONS

  1. PHP Interview Questions And Answers
  2. Alteryx Interview Questions
  3. AWS Cloud Support Interview Questions
  4. Google Kubernetes Engine Interview Questions
  5. AWS Devops Interview Questions
  6. Apigee Interview Questions
  7. Actimize Interview Questions
  8. Kibana Interview Questions
  9. Nagios Interview Questions
  10. Jenkins Interview Questions
  11. Chef Interview Questions
  12. Puppet Interview Questions
  13. DB2 Interview Questions
  14. AnthillPro Interview Questions
  15. Angular 2 Interview Questions
  16. Hibernate Interview Questions
  17. ASP.NET Interview Questions
  18. Kubernetes Interview Questions
  19. Docker Interview Questions
  20. CEH Interview Questions
  21. CyberArk Interview Questions
  22. Appian Interview Questions
  23. Drools Interview Questions
  24. Talend Interview Questions
  25. Selenium Interview Questions
  26. Ab Initio Interview Questions
  27. AB Testing Interview Questions
  28. Mobile Application Testing Interview Questions
  29. Pega Interview Questions
  30. UI Developer Interview Questions

Advanced PHP Interview Questions And Answers

PHP Interview Questions And Answers For Experienced 2018. Here in this article, we are providing a list of 135 real-time scenario based PHP interview questions for freshers and professionals. This list includes PHP interview questions for 1 year experience, 2 year experience, 3 year experience, 4 year experience, 5 year experienced PHP developers and experienced PHP programmers.

PHP Interview Questions

Must Read PHP Interview Questions Books

Core PHP Interview Questions

  1. What is PHP?
  2. What is PHP and why it is used?
  3. Why PHP was called as personal home page?
  4. What is PHP compared to HTML?
  5. What is a PHP 5?
  6. What is PHP and what does it do?
  7. What is the difference between PHP and Javascript?
  8. What is the difference between HTML and PHP?
  9. What are the advantages of using PHP?
  10. What is the difference between Python and PHP?

PHP Interview Questions And Answers

These 135 advanced PHP interview questions and answers were written by PHP experienced professionals to help senior PHP developers. This is one place for all beginners to experienced PHP programmers for basic interview questions to most advanced PHP technical interview questions and answers. Let’s dive into the post and enjoy reading. We hope that this list will help you to crack your next PHP job interview. Happy learning.

PHP Interview Questions And Answers For Freshers

Question # 1) What is PHP?

Answer # PHP: Hypertext Preprocessor is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

 

Question # 2) What is PHP and why it is used?

Answer # PHP is a general-purpose scripting language that is especially suited to server-side web development, in which case PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on websites or elsewhere.

 

Question # 3) Why PHP was called as personal home page?

Answer # php is called hypertext pre-processor as its libraries are already compiled. When any person request for any php page in the address bar of the browser that request is first sent to the server then server interpret php files and return back response in form of Html.

 

Question # 4) What is PHP compared to HTML?

Answer # HTML is a language used to describe to a browser how to display text and other objects in a browser window. It is not a programming language. HTML works on a client computer (the system on which the page is being viewed). PHP is a scripting language, and can be used to create web pages written in HTML.

 

Question # 5) What is a PHP 5?

Answer # PHP 5 is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft’s ASP.

Top PHP Interview Questions

Question # 6) What is PHP and what does it do?

Answer # PHP is mainly focused on server-side scripting, so you can do anything any other CGI program can do, such as collect form data, generate dynamic page content, or send and receive cookies. But PHP can do much more. There are three main areas where PHP scripts are used. Server-side scripting.

 

Question # 7) What is the difference between PHP and Javascript?

Answer # While JS is used for client side scripting (except in node.js) and PHP is used for server side scripting. Simply, JavaScript codes are executed by your web browser, like the catchy animations or simple calculations . Your browser does all the processing. While PHP runs on the server, where your webpage is stored.

 

Question # 8) What is the difference between HTML and PHP?

Answer # HTML is a language used to describe to a browser how to display text and other objects in a browser window. It is not a programming language. HTML works on a client computer (the system on which the page is being viewed). PHP is a scripting language, and can be used to create web pages written in HTML.

PHP Interview Questions And Answers

Question # 9) What are the advantages of using PHP?

Answer # Advantages of PHP Programming. PHP (Hypertext Pre-Processor) is a server-side web programming language that is widely used for web development. However, here are many languages which are used for web development or web programming. … PHP can run on both UNIX and Windows servers.

 

Question # 10) What is the difference between Python and PHP?

Answer # PHP is a language that’s made for the web. You can make GTK and CLI applications with PHP, but it’s mainly used for websites. Python is used for a lot of stuff like websites, webservers, game frameworks, desktop and CLI application, IDEs and a lot more. There’s also a huge difference in the syntax.

Basic PHP Interview Questions

Question # 11) Why do we use PHP?

Answer # A good benefit of using PHP is that it can interact with many different database languages including MySQL. We work with MySQL at Bluelinemedia since this is also a free language so it makes sense to use PHP. Both PHP and MySQL are compatible with an Apache server which is also free to license.

PHP Interview Questions And Answers

Question # 12) What is a session in PHP?

Answer # PHP 5 Sessions – A session is a way to store information (in variables) to be used across multiple pages. Unlike a cookie, the information is not stored on the users computer.

 

Question # 13) Why is Facebook still using PHP?

Answer # Facebook technology stack consist of application written in many language, including PHP and many others. Facebook still using PHP but it has built a compiler for it so it can be turned into native code on. Facebook doesn’t use PHP for its core system, at Facebook, they uses C++ heavily on back end system.

 

PHP Interview Questions And Answers For 1 Year Experience

 

Question # 14) How does PHP work?

Answer # The PHP software works with the web server, which is the software that delivers web pages to the world. You request a file, the web server happens to be running PHP, and it sends HTML back to the browser, thanks to the programming in PHP.

PHP Interview Questions And Answers

Question # 15) Can you use PHP and Javascript together?

Answer # So, when we develop web pages, we can have a combination of HTML, Javascript, CSS and PHP in our pages. If you need to use a scripting language, such as PHP, once the page has been loaded into the browser, then you must either refresh the page or use Ajax to request more processing at the server side.

 

Question # 16) Why do we use Javascript in PHP?

Answer # PHP is commonly written in-line in the same files as HTML and Javascript, PHP is a server-side language. Javascript is a client-side language. The main difference here is not PHP vs. JavaScript. It’s Client vs. Server. You can’t do server stuff on the client, and you can’t do all the Client stuff on the Server.

 

Question # 17) What is the main difference between asp net and PHP?

Answer # PHP is a programming language whereas ASP.NET is a programming framework. Websites developed by ASP.NET may use C#, but also other languages such as J#. ASP.NET is compiled whereas PHP is interpreted. ASP.NET is designed for windows machines, whereas PHP is platform free (and typically runs on Linux servers).

PHP Interview Questions And Answers

Question # 18) How does session work in PHP?

Answer # the session id is sent to the user when his session is created. it is stored in a cookie (called, by default, PHPSESSID ) that cookie is sent by the browser to the server with each request. the server (PHP) uses that cookie, containing the session_id, to know which file corresponds to that user.

 

Question # 19) How do you end a session in PHP?

Answer # If you want to explicitly end a user’s and delete their data without them having to close their browser, you need to clear the $_SESSION array, then use the session_destroy() function. Session_destroy() removes all session data stored on your hard disk, leaving you with a clean slate.

 

Question # 20) What are the advantages of PHP mysql?

Answer # It is a stable, reliable and powerful solution with advanced features like the following:

  • Data Security
  • On-Demand Scalability
  • High Performance
  • Round-the-clock Uptime
  • Comprehensive Transactional Support
  • Complete Workflow Control
  • Reduced Total Cost of Ownership
  • The Flexibility of Open Source

Core PHP Interview Questions

Question # 21) Is Java is better than PHP?

Answer # PHP and Java are both very similar when it comes to the benefits provided, but they are both very different. PHP is a server side scripting language, while Java is a client side choice. When you use PHP code, you will execute it in the actual server, while Java will be executed on your client’s computer.

PHP Interview Questions And Answers

Question # 22) How do I install PHP?

Answer # Here ie the Manual Installation Procedure

Step 1: download the files. Download the latest PHP 5 ZIP package from www.php.net/downloads.php

Step 2: extract the files

Step 3: configure php.ini

Step 4: add C:php to the path environment variable

Step 5: configure PHP as an Apache module

Step 6: test a PHP file

 

Question # 23) What is the use session in PHP?

Answer # This can be used to persist state information between page requests. Session IDs are normally sent to the browser via session cookies and the ID is used to retrieve existing session data. PHP will populate the $_SESSION superglobal with any session data after the session has started.

 

Question # 24) How long does a session last in PHP?

Answer # This is the one. The session will last for 1440 seconds (24 minutes).

 

Question # 25) What is the use of PHP and Mysql?

Answer # PHP is the most popular scripting language for web development. It is free, open source and server-side (the code is executed on the server). MySQL is a Relational Database Management System (RDBMS) that uses Structured Query Language (SQL).

 Latest PHP Interview Questions

Question # 26) Is jquery better than Javascript?

Answer # It may surprise you to learn that JavaScript and jQuery are actually the same thing. In a nutshell, jQuery is a set of JavaScript libraries that have been designed specifically to simplify HTML document traversing, animation, event handling, and Ajax interactions.

PHP Interview Questions And Answers

Question # 27) What is the difference between interpreted and compiled languages?

Answer # Java (interpreted) and C (or C++) (compiled) might have been a better example. Basically, compiled code can be executed directly by the computer’s CPU. The code of interpreted languages however must be translated at run-time from any format to CPU machine instructions. This translation is done by an interpreter.

 

Question # 28) How does cookies work in PHP?

Answer # A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.

 

Question # 29) How do I update PHP?

Answer # Changing the PHP Version:

  1. Log  into cPanel.
  2. Click the PHP Configuration button in the Software section.
  3.  Select the version of PHP you want to use from the dropdown.
  4. Click the Update button to save your php configuration.
  5.  Check your changes by viewing your settings in a phpinfo page.

 

Question # 30) What is the use of session and cookies in PHP?

Answer # A session is a global variable stored on the server. Each session is assigned a unique id which is used to retrieve stored values. Sessions have the capacity to store relatively large data compared to cookies. The session values are automatically deleted when the browser is closed.

 

Question # 31) What is in PHP 7?

Answer # Designed and refactored for today’s workloads, PHP 7 is the ultimate choice for web developers today. Get started now. Faster performance, less resources, and cool new features like scalar type declarations, the Spaceship Operator, anonymous classes, and more.

PHP Interview Questions And Answers

Question # 32) WHAT IS NULL value in PHP?

Answer # In the PHP world, apparantly uninitialized variables have the Null value, and is set on such a variable returns FALSE.

 

Question # 33) What is a trait in PHP?

Answer # Traits are a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.

 

Question # 34) What is is_null() in PHP?

Answer # The is_null () function is used to test whether a variable is NULL or not. *Mixed : Mixed indicates that a parameter may accept multiple (but not necessarily all) types. Returns TRUE if var_name is null, FALSE otherwise.

PHP Interview Questions And Answers

Question # 35) What is the difference between null and empty?

Answer # An empty string is a value, but is just empty. Null is special to a database. Null has no bounds, it can be used for string , integer , date , etc. fields in a database. NULL isn’t allocated any memory, the string with NUll value is just a pointer which is pointing to nowhere in memory.

 

PHP Interview Questions And Answers For 2 Year Experience

 

Question # 36) What is a closure in PHP?

Answer # A closure is an object representation of an anonymous function. We can see that the anonymous function in the above code actually returns an object of closure which is assigned to and called using the variable $string. You can say closure is an object oriented way to use anonymous functions.

 

Question # 37) What is final in PHP?

Answer # PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

PHP Interview Questions And Answers

Question # 38) What is Var_dump?

Answer # The var_dump function displays structured information about variables/expressions including its type and value. Arrays are explored recursively with values indented to show structure. It also shows which array values and object properties are references.

 

Question # 39) What is the difference between null and undefined?

Answer # undefined means a variable has been declared but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value. Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.

PHP Interview Questions And Answers

Question # 40) What is the use of callback in PHP?

Answer # PHP callback are functions that may be called dynamically by PHP. They are used by native functions such as array_map, usort, preg_replace_callback, etc. Here is a reminder of the various ways to create a callback function in PHP, and use it with the native functions.

Advanced PHP Interview Questions

Question # 41) What is a lambda function in PHP?

Answer # To sum up, a lambda function is an anonymous PHP function that can be stored in a variable and passed as an argument to other functions or methods. A closure is a lambda function that is aware of its surrounding context.

PHP Interview Questions And Answers

Question # 42) What is overriding in PHP?

Answer # Overloading is defining functions that have similar signatures, yet have different parameters. Overriding is only pertinent to derived classes, where the parent class has defined a method and the derived class wishes to override that method. In PHP, you can only overload methods using the magic method __call.

 

Question # 43) What is encapsulation in PHP?

Answer # Encapsulation is an OOP (Object Oriented Programming) concept in PHP. Wrapping some data in single unit is called Encapsulation. Second advantage of encapsulation is you can make the class read only or write only by providing setter or getter method. Capsule is best example of Encapsulation.

PHP Interview Questions And Answers

Question # 44) What is boolean in PHP?

Answer # PHP Booleans. A Boolean value is one that is in either of two states. They are known as True or False values, in programming. True is usually given a value of 1, and False is given a value of zero.

 

Question # 45) What is the use of Print_r function in PHP?

Answer # prinf : It is a function which takes atleast one string and format style and returns length of output string. print_r() is used for printing the array in human readable format. they both are language constructs. echo returns void and print returns 1.

 

Question # 46) What is the use of anonymous function in PHP?

Answer # Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses. Anonymous functions are implemented using the Closure class.

PHP Interview Questions And Answers

Question # 47) What is polymorphism in PHP?

Answer # Polymorphism is a long word for a very simple concept. Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.

 

Question # 48) What is the use of magic function in PHP?

Answer # PHP provides a number of ‘magic’ methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met.

PHP Interview Questions And Answers

Question # 49) What is the use of return in PHP?

Answer # (PHP 4, PHP 5, PHP 7) return returns program control to the calling module. Execution resumes at the expression following the called module’s invocation. If called from within a function, the return statement immediately ends execution of the current function, and returns its argument as the value of the function call.

 

Question # 50) What is the use of die in PHP?

Answer # The die() function prints a message and exits the current script. This function is an alias of the exit() function.

PHP Developer Interview Questions

Question # 51) What is an array in PHP?

Answer # PHP Arrays – An array is a data structure that stores one or more similar type of values in a single value. For example if you want to store 100 numbers then instead of defining 100 variables its easy to define an array of 100 length.

 

Question # 52) How to write comment in php?

Answer # Similiar to the HTML comment, the multi-line PHP comment can be used to comment out large blocks of code or writing multiple line comments. The multiple line PHP comment begins with ” /* ” and ends with ” */ “.

PHP Interview Questions And Answers

Question # 53) What is the difference between $message and $$message in PHP?

Answer # They are both variables. But $message is a variable with a fixed name. $$message is a variable who’s name is stored in $message. For example, if $message contains “var”, $$message is the same as $var.

 

Question # 54) What is the difference between require and include in PHP?

Answer # Require and include functions does the same task i.e. includes and evaluates specified file, but the difference is require will cause a fatal error when the specified file location is invalid or for any error where as include will generate a warning and continue the code execution.

 

PHP Interview Questions And Answers For 3 Year Experience

 

Question # 55) What are the different types of errors in PHP?

Answer # There are four types of errors in PHP.

  1. Warning errors
  2. Notice errors
  3. Fatal errors
  4. Parse errors

Question # 56) PHP Error Constants and their descriptions

Answer #

  1. E_ERROR: A fatal error that causes script termination
  2. E_WARNING: Run-time warning that does not cause script termination
  3. E_PARSE: Compile time parse error
  4. E_NOTICE: Run time notice caused due to error in code
  5. E_CORE_ERROR: Fatal errors that occur during PHP’s initial startup (installation)
  6. E_CORE_WARNING: Warnings that occur during PHP’s initial startup
  7. E_COMPILE_ERROR: Fatal compile-time errors indication problem with script
  8. E_USER_ERROR: User-generated error message
  9. E_USER_WARNING: User-generated warning message
  10. E_USER_NOTICE: User-generated notice message
  11. E_STRICT: Run-time notices
  12. E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
  13. E_ALL: Catches all errors and warnings
  14. E_DEPRECATED
  15. E_USER_DEPRICATED

Question # 57) What is the use of Include_once in PHP?

Answer # The include_once statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include statement, with the only difference being that if the code from a file has already been included, it will not be included again, and include_once returns TRUE .

PHP Interview Questions And Answers

Question # 58) What is Exception Handling in PHP?

Answer # With PHP 5 came a new object oriented way of dealing with errors. Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception.

 

Question # 59) Why post method is used in PHP?

Answer # GET can’t be used to send binary data, like images or word documents, to the server. The data sent by GET method can be accessed using QUERY_STRING environment variable. The PHP provides $_GET associative array to access all the sent information using GET method. The POST method transfers information via HTTP headers.

PHP Interview Questions And Answers

Question # 60) What is the use of post in PHP?

Answer # When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named “welcome.php”. The form data is sent with the HTTP POST method. To display the submitted data you could simply echo all the variables.

Senior PHP Developer Interview Questions And Answers

Question # 61) What is the difference between require_once and require in PHP?

Answer # require() includes and evaluates 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 when you want to include a file where you have a lot of functions for example.

 

Question # 62) What is the use of die in PHP?

Answer # The die() function prints a message and exits the current script. This function is an alias of the exit() function.

 

Question # 63) How do you debug PHP?

Answer # To run a debugging session: Start the ide and open the file that contains the source code that you want to debug. Set a breakpoint at each line where you want the debugger to pause. To set a breakpoint, place the cursor at the beginning of a line and press Ctrl-F8/⌘-F8 or choose Debug > Toggle Line Breakpoint.

PHP Interview Questions And Answers

Question # 64) What is the meaning of xdebug?

Answer # Xdebug is a PHP extension which provides debugging and profiling capabilities. It uses the DBGp debugging protocol.

 

Question # 65) What is Chrome logger?

Answer # Chrome Logger is a Google Chrome extension for debugging server side applications in the Chrome console. Most languages include their own logging capabilities, but sometimes it is easier to see your logs right in the browser. Chrome Logger used to be known as ChromePHP.

PHP Developer Interview Questions And Answers For Experienced Candidates

Question # 66) What is the Phpstorm?

Answer # JetBrains PhpStorm is a commercial, cross-platform IDE for PHP built on JetBrains’ IntelliJ IDEA platform. PhpStorm provides an editor for PHP, HTML and JavaScript with on-the-fly code analysis, error prevention and automated refactorings for PHP and JavaScript code.

PHP Interview Questions And Answers

Question # 67) What is Zend Studio for?

Answer # Zend Studio is a commercial, proprietary integrated development environment (IDE) for PHP developed by Zend Technologies, based on the PHP Development Tools (PDT) plugin for the Eclipse platform (the PDT project is led by Zend). … Zend Studio is also integrated with Zend Framework.

 

Question # 68) What is urlencode and urldecode in php?

Answer # urlencode(string) — This PHP function is encodes a string to be used in a query part of a URL. URL encoding is used when placing text in a query string to avoid it being confused with the URL itself. It is normally used when the browser sends form data to a web server.

urldecode(string) – This PHP function id decodes any encoded value in the given string.

 

Question # 69) What is LAMP in PHP?

Answer # LAMP is a combination of Linux, Apache, MySQL and PHP.

PHP Interview Questions And Answers

Question # 70) What is the maximum size of a database in mysql?

Answer #

Operating System            File-size Limit

Win32 w/ FAT/FAT32      2GB/4GB

Win32 w/ NTFS 2TB (possibly larger)

Linux 2.2-Intel 32-bit      2GB (LFS: 4GB)

Linux 2.4+(using ext3 file system) 4TB

Solaris 9/10         16TB

MacOS X w/ HFS+            2TB

NetWare w/NSS file system        8TB

PHP Programming Questions

Question # 71) What is the maximum size of a table in MySQL?

Answer # You are using a MyISAM table and the space required for the table exceeds what is permitted by the internal pointer size. MyISAM permits data and index files to grow up to 256TB by default, but this limit can be changed up to the maximum permissible size of 65,536TB (2567 − 1 bytes).

 

Question # 72) What is the capacity of MySQL database?

Answer # Database Storage Capacity. MySQL is limited by the largest file size that the operating system you run it on can handle (between 4Gb and 256Tb depending on the O/S). With the innoDB table format you can even span multiple files with one table allowing for tables in the database of up to 64Tb.

PHP Interview Questions And Answers

Question # 73) How many records can be stored in MySQL table?

Answer # In InnoDB, with a limit on table size of 64 terabytes and a MySQL row-size limit of 65,535 there can be 1,073,741,824 rows. That would be minimum number of records utilizing maximum row-size limit. However, more records can be added if the row size is smaller.

 

Question # 74) How many columns can be added in a table in mysql?

Answer # MySQL 5.0 Column Count Limits: There is a hard limit of 4096 columns per table, but the effective maximum may be less for a given table. The exact limit depends on several interacting factors. Every table (regardless of storage engine) has a maximum row size of 65,535 bytes.

PHP Interview Questions And Answers

Question # 75) What is varchar mysql?

Answer # Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

 PHP Programming Interview Questions

Question # 76) How big is varchar Max?

Answer # n defines the string length and can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size is the actual length of the data entered + 2 bytes. The ISO synonyms for varchar are charvarying or charactervarying.

 

Question # 77) Why triggers are used in mysql?

Answer # The MySQL trigger is a database object that is associated with a table. It will be activated when a defined action is executed for the table. The trigger can be executed when you run one of the following MySQL statements on the table: INSERT, UPDATE and DELETE and it can be invoked before or after the event.

PHP Interview Questions And Answers

Question # 78) How big is Nvarchar Max?

Answer # In Nvarchar “n” defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size, in bytes, is two times the actual length of data entered + 2 bytes. The ISO synonyms for nvarchar are national char varying and national character varying.

 

Question # 79) Why delimiter is used in mysql?

Answer # By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server. To redefine the mysql delimiter, use the delimiter command.

 

Question # 80) What is a stored procedure in mysql?

Answer # A procedure (often called a stored procedure) is a subroutine like a subprogram in a regular computing language, stored in database. A procedure has a name, a parameter list, and SQL statement(s). All most all relational database system supports stored procedure, MySQL 5 introduce stored procedure.

PHP Technical Interview Questions

Question # 81) What does a delimiter do in mysql?

Answer # delimiter is the marker for the end of each command you send to the mysql command line client. delimiter is not only related to triggers, but defining triggers and stored procedures is one strong use case as you wish them to contain semicolons (;) which are otherwise the default delimiter.

 

Question # 82) What is a definer in mysql?

Answer # All stored programs (procedures, functions, triggers, and events) and views can have a DEFINER attribute that names a MySQL account. If the DEFINER attribute is omitted from a stored program or view definition, the default account is the user who creates the object.

PHP Interview Questions And Answers

Question # 83) When should you use a stored procedure?

Answer # The benefits of using stored procedures in SQL Server rather than application code stored locally on client computers include: They allow modular programming. They allow faster execution. They can reduce network traffic.

 

Question # 84) What is the use of limit in mysql?

Answer # Limit Data Selections From a MySQL Database. MySQL provides a LIMIT clause that is used to specify the number of records to return. The LIMIT clause makes it easy to code multi page results or pagination with SQL, and is very useful on large tables. Returning a large number of records can impact on performance.

PHP Interview Questions And Answers

Question # 85) What is the use of dual table in mysql?

Answer # The DUAL table is a special one-row, one-column table present by default in Oracle and other database installations. In Oracle, the table has a single VARCHAR2(1) column called DUMMY that has a value of ‘X’. It is suitable for use in selecting a pseudo column such as SYSDATE or USER.

Advanced PHP Interview Questions

Question # 86) What is the use of inner join in mysql?

Answer # The MySQL INNER JOIN clause matches rows in one table with rows in other tables and allows you to query rows that contain columns from both tables. The INNER JOIN clause is an optional part of the SELECT statement.

 

Question # 87) What is the difference between an inner and outer join?

Answer # An inner join will only select records where the joined keys are in both specified tables. A left outer join will select all records from the first table, and any records in the second table that match the joined keys.

 

Question # 88) What is the use of offset in mysql?

Answer # Both MySQL and PostgreSQL support a really cool feature called OFFSET that is usually used with a LIMIT clause. The LIMIT clause is used to limit the number of results returned in a SQL statement.

PHP Interview Questions And Answers For 4 Year Experience

Question # 89) What is stdClass in PHP?

Answer # stdClass is a PHP generic empty class and stdClass is used to create the new Object.  stdClass is a kind of Object in Java or object in Python but not actually used as universal base class.

 

Question # 90) What are soundex() and metaphone() functions in PHP?

Answer # soundex and metaphone can be used to find strings that sound similar when pronounced out loud.

soundex() function calculates the soundex key of a string. A soundex key is a four character long alphanumeric strings that represents English pronunciation of a word.

metaphone() the metaphone() function calculates the metaphone key of a string. A metaphone key represents how a string sounds if pronounced by an English person.

PHP Interview Questions And Answers

Question # 91) How to parse configuration file in PHP?

Answer # The parse_ini_file() function parses a configuration (ini) file and returns the settings.

 

Question # 92) What is PSR in PHP?

Answer # The PHP Standard Recommendation (PSR) is a PHP specification published by the PHP Framework Interop Group. Similar to Java Specification Request for Java, it serves the standardization of programming concepts in PHP.

PHP Logical Interview Questions And Answers

Question # 93) What is Trait in PHP?

Answer # Traits are a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.

 

Question # 94) What is the difference between php traits vs interfaces?

Answer # The main difference is that, with interfaces, you must define the actual implementation of each method within each class that implements said interface, so you can have many classes implement the same interface but with different behavior, while traits are just chunks of code injected in a class.

PHP Interview Questions And Answers

Question # 95) Can you give example for Trait in PHP?

Answer #

<?php

trait ezcReflectionReturnInfo {

function getReturnType() { /*1*/ }

function getReturnDescription() { /*2*/ }

}

class ezcReflectionMethod extends ReflectionMethod {

use ezcReflectionReturnInfo;

/* … */

}

class ezcReflectionFunction extends ReflectionFunction {

use ezcReflectionReturnInfo;

/* … */

}

?>

 

Question # 96) How to get IP address of a server in PHP?

Answer # Try $_SERVER[‘SERVER_ADDR’] . It will be the IP address that the server is listening on. You can use DNS functions (e.g., gethostbyaddr() ) to get the host name.

 

Question # 97) Is there an easy way to delete an element from a PHP array?

Answer # If we want to delete just one array element you can use unset() method or alternative array_splice() method. Also if you have the value and don’t know the key to delete the element you can use array_search() method to get the key.

PHP Interview Questions And Answers For Experienced

Question # 98) Can you explain, when to use If-else if-else over switch statements?

Answer # If there is switching on the value of a single variable then switch is recommended every time. Otherwise, stick with multiple if-else statements.

 

Question # 99)  When do you use define() and when do you use const. What are the main differences between those two?

Answer # PHP 5.3 there are two ways to define constants: Either using the const keyword or using the  define() function:

const FOO = ‘BAR’;

define(‘FOO’, ‘BAR’);

The fundamental difference between those two ways is that const defines constants at compile time, whereas define() defines them at runtime. As const are language constructs and defined at compile time they are a bit faster than define().

PHP Interview Questions And Answers For 5 Year Experience

 

Question # 100) What is self in PHP?

Answer # In PHP self keyword is used to access static properties and methods.

 

Question # 101) What is $this?

Answer # It is the way to reference an instance of a class from within itself, the same as many other object-oriented languages.  $this refers to the class you are in. In PHP, the pseudo-variable $this is available when a method is called from within an object context.

PHP Interview Questions And Answers

Question # 102) When to use self over $this?

Answer # Use $this to refer to the current object. Use self to refer to the current class.

 

Question # 103) What is the difference between Apache and Tomcat?

Answer # Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat. So basically Apache is an HTTP Server, serving HTTP. Tomcat is a Servlet and JSP Server serving Java technologies.

 

Question # 104) What is Nginx and what is it used for?

Answer # NGINX (Pronounced as Engine-X) is an open source, lightweight, high-performance web server or proxy server. Nginx used as reverse proxy server for HTTP, HTTPS, SMTP, IMAP, POP3 protocols, on the other hand, it is also used for servers load balancing and HTTP Cache.

PHP Interview Questions And Answers

Question # 105) Which is the best Web server?

Answer # There are different web servers available for different technologies.

LAMP: Linux, Apache, MySQL and PHP.

WIMP: Windows, IIS, MySQL/MS SQL Server and PHP.

WAMP: Windows, Apache, MySQL/MS SQL Server and PHP.

LEMP: Linux, NGINX, MySQL and PHP.

PHP Interview Questions And Answers For Experienced Candidates

Question # 106) What is the difference between Apache vs NIGINX?

Answer # The Apache HTTP server and NGINX are the two most popular open source web servers in the world today. The Apache web servers have been in use since 1995. Apache powers more websites than any other product. Because the open-source Apache web server has been available for so many years, and has so many users, lots of modules have been written to expand its functionality.

But Apache slows down under heavy load, because of the need to spawn new processes, thus consuming more computer memory. It also creates new threads that must compete with others for access to memory and CPU. Apache will also refuse new connections when traffic reaches the limit of processes configured by the administrator.

Nginx is an open source web server written to address some of the performance and scalability issues associated with Apache. The product is open source and free, but Nginx offers support if you buy its Nginx Plus version. Nginx is indeed event-based. They call their architecture “event-driven and asynchronous”. Apache relies on processes and threads.

PHP Interview Questions And Answers

Question # 107) What is .htaccess in PHP?

Answer # .htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn ‘loaded via the Apache Web Server’, then the .htaccess file is detected and executed by the Apache Web Server software.

 

Question # 108) What are advantages of .htaccess?

Answer # There are many advantages using .htaccess file in PHP:

  • URL redirecting
  • Managing error pages
  • Password Protection
  • Visitor blocking facilities by IP address
  • Setting Config variable and Environment variable

PHP Interview Questions And Answers

Question # 109) How to redirect a URL from http to https in .htaccess?

Answer # Using this below code, we can redirect a URL from http to https

RewriteEngine on

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

 

Question # 110) How to redirect https to http URL and vice versa in .htaccess?

Answer # Using this below code, we can redirect a URL from http to https

Redirect https to http

RewriteEngine On

RewriteCond %{HTTPS} on

RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Real Time PHP Interview Questions And Answers

Question # 111) What is a composer in PHP?

Answer # Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries.

 

Question # 112) What is PHP artisan?

Answer # Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.

 

Question # 113) What is the difference between == and === in PHP?

Answers # The difference between the loosely == equal operator and the strict === identical operator is:

$a ==  $b │ Equal     │ TRUE if $a is equal to $b after type juggling.

$a === $b │ Identical │ TRUE if $a is equal to $b, and they are of the same type.

PHP Interview Questions And Answers

Question # 114) What is the output of the following PHP code?

Answers: $i = 012;

echo $i / 2;

Explanation: You might think that output for the above code is 6 right. That’s the wrong answer. But the correct output should be 5. The zero indicates at the beginning of a number as an octal number in PHP, so the number 012 evaluates to the decimal number 10 instead to decimal 12. Then the output should be 5.

MySQL Interview Questions And Answers For Experienced

Question # 115) What is SQL injection?

Answers # SQL injection (or a SQL injection attack) occurs when a user provides SQL code as user input for a Web page, and the SQL code is then executed in the database.

 

Question # 116) Why does SQL injection happen?

Answers # SQL injection is an attack technique that exploits a security vulnerability occurring in the database layer of an application . Hackers use injections to obtain unauthorized access to the underlying data, structure, and DBMS. It is one of the most common web application vulnerabilities.

PHP MYSQL Interview Questions And Answers

Question # 117) What is Mysql_real_escape_string used for?

Answers # In the case of MySQL this means: mysql_real_escape_string() calls MySQL’s library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ‘, ” and \x1a.

 

Question # 118) What is input sanitization in PHP?

Answers # PHP filters are used to validate and sanitize external input. The PHP filter extension has many of the functions needed for checking user input, and is designed to make data validation easier and quicker.

 

Question # 119) What is the use of Stripslashes in PHP?

Answers # Definition and Usage. The stripslashes() function removes backslashes added by the addslashes() function. This function can be used to clean up data retrieved from a database or from an HTML form.

 

Question # 120) What is the use of Htmlspecialchars in PHP?

Answers # In many PHP legacy products the function htmlspecialchars($string) is used to convert characters like < and > and quotes a.s.o to HTML-entities.

 

Question # 121) What is the use of Addslashes in PHP?

Answers # Description. string addslashes ( string $str ) Returns a string with backslashes before characters that need to be escaped. These characters are single quote (‘), double quote (“), backslash (\) and NUL (the NULL byte).

PHP Interview Questions And Answers

Question # 122) What is XSS in PHP?

Answers # Cross-Site Scripting (abbreviated as XSS) is a class of security vulnerability whereby an attacker manages to use a website to deliver a potentially malicious JavaScript payload to an end user. XSS vulnerabilities are very common in web applications.

 

Question # 123) What is the use of isset in PHP?

Answers # isset() function. The isset () function is used to check whether a variable is set or not. If a variable is already unset with unset() function, it will no longer be set. The isset() function return false if testing variable contains a NULL value.

Real Time PHP Interview Questions And Answers

Question # 124) What is URL encoding and decoding in PHP?

Answers # urlencode(string)  This PHP function encodes a string to be used in a query part of a URL. urldecode(string) — This PHP function is decodes the query part of a URL string. URL encoding is used when placing text in a query string to avoid it being confused with the URL itself.

 

Question # 125) What is the use of trim in PHP?

Answers # The trim() function removes whitespace and other predefined characters from both sides of a string.

Related functions: ltrim() – Removes whitespace or other predefined characters from the left side of a string.

rtrim() – Removes whitespace or other predefined characters from the right side of a string.

PHP Interview Questions And Answers

Question # 126) What is the mysql injection?

Answers # MySQL injection refers to the act of someone inserting a MySQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement that you will unknowingly run on your database.

 

Question # 127) What is the use of die in PHP?

Answers # The die() function prints a message and exits the current script. This function is an alias of the exit() function.

 

Question # 128) What does explode do in PHP?

Answers # You can also convert between strings and arrays by using the PHP implode and explode functions: implode implodes an array to a string, and explode explodes a string into an array.

PHP Interview Questions And Answers

Question # 129) What are the delimiters in PHP?

Answers # When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character. Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).

 

Question # 130) Why Print_r is used in PHP?

Answers # print_r() is used for printing the array in human-readable format.

Scenario-Based PHP Interview Questions And Answers

Question # 131) What is Var_dump?

Answers # The var_dump function displays structured information about variables/expressions including its type and value.

 

Question # 132) What are the new features available in PHP 7?

Answers # New features from PHP 7 are:

  • Scalar type declarations – Scalar type declarations come in two flavors. One is coercive and the other one is strict.
  • Return type declarations
  • Null coalescing operator
  • Spaceship operator
  • Constant arrays using define()
  • Anonymous classes
  • Unicode codepoint escape syntax
  • Closure::call()

Question # 133) How do you define a constant in PHP?

Answers # A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or underscore (no $ sign before the constant name).

PHP Interview Questions And Answers

Question # 134) What is Warning – “Cannot modify header information – headers already sent”?

Answers # In PHP when you output something (do an echo or print) if has to send the HTTP headers at that time. If you turn on output buffering you can output in the script but PHP doesn’t have to send the headers until the buffer is flushed. This will turn output buffering out without the need to call ob_start().

Accenture PHP Interview Questions And Answers

Question # 135) Explain about getters and setters in PHP?

Answers # “Getters” and “Setters” are object methods that allow you to control access to a certain class variables / properties. Sometimes, these functions are referred to as “mutator methods”. A “getter” allows to you to retrieve or “get” a given property. A “setter” allows you to “set” the value of a given property.

PHP Interview Questions And Answers

Question # 136) What are majic methords in PHP?

Answers # PHP provides a number of ‘magic’ methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met.

Give me some examples of majix methods?

__construct()

The __construct() method is by far the most commonly used magic method. This is where you do any initialization you need when an object is created.

__destruct()

The __destruct() method is called when the object is destroyed. It accepts no arguments and is commonly used to perform any cleanup operations such as closing a database connection.

__get()

The __get() method is called when code attempts to access a property that is not accessible. It accepts one argument, which is the name of the property. It should return a value, which will be treated as the value of the property.

__set()

The __set() method is called when code attempts to change the value a property that is not accessible. It accepts two arguments, which are the name of the property and the value.

__isset()

The __isset() method is called when code calls isset() on a property that is not accessible. It accepts one argument, which is the name of the property. It should return a Boolean value representing the existence of a value.

__unset()

The __unset() method is called when code attempts to unset() a property that is not accessible. It accepts one argument, which is the name of the property.

__toString()

The __toString() method is called when code attempts to treat an object like a string. It accepts no arguments and should return a string.

__set_state()

The static __set_state() method is called when the var_export() function is called on our object.

__clone()

The __clone() method can be used to solve this problem. It is called on the copy of a cloned object after cloning takes place.

__sleep()

The __sleep() method is called when the serialize() function is called on the object. It accepts no arguments and should return an array of all properties that should be serialized.

__wakeup()

The __wakeup() method is called when the unserialize() function is called on the stored object. It accepts no arguments and does not need to return anything. Use it to reestablish any database connection.

__call()

The __call() is called when code attempts to call inaccessible or nonexistent methods. It accepts two arguments: the name of the called method and an array of arguments.

__callStatic()

The __callStatic() (available as of PHP version 5.3) is identical to __call() except that it is called when code attempts to call inaccessible or nonexistent methods in a static context.

__invoke()

The __invoke() is called when code tries to use the object as a function. Any arguments defined in this method will be used as the function arguments.

__autoload()

This is not a magic method, but it is still very useful. The __autoload() function is automatically called when a class that doesn’t exist is referenced.

Coding compiler hope that these 136 PHP interview questions and answers for freshers and 1 2 3 4 5 years experienced professionals will help you to crack your next PHP job interview. If you know any other PHP technical interview questions, please write in below comment box, these PHP questions will be helpful for fellow PHP professionals.

RELATED INTERVIEW QUESTIONS

  1. Kubernetes Interview Questions
  2. Docker Interview Questions
  3. CEH Interview Questions
  4. CyberArk Interview Questions
  5. Appian Interview Questions
  6. Drools Interview Questions
  7. Talend Interview Questions
  8. Selenium Interview Questions
  9. Ab Initio Interview Questions
  10. AB Testing Interview Questions
  11. Mobile Application Testing Interview Questions
  12. Pega Interview Questions
  13. UI Developer Interview Questions
  14. Tableau Interview Questions
  15. SAP ABAP Interview Questions
  16. Reactjs Interview Questions
  17. UiPath Interview Questions
  18. Automation Anywhere Interview Questions
  19. RPA Interview Questions
  20. RPA Blue Prism Interview Questions
  21. Ranorex Interview Questions
  22. AWS Interview Questions
  23. SSRS Interview Questions
  24. SQL Interview Questions
  25. Informatica MDM Interview Questions
  26. CyberArk Interview Questions
  27. SAP SD Interview Questions
  28. SAP EWM Interview Questions
  29. Advanced Javascript Interview Questions
  30. Angular 2 Interview Questions