Top PHP Interview Questions 2018 – part2

In this article, we provide PHP Interview Questions which you can use to crack any level of php interview. Feel free to ask any question in questionbank.

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.

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:

– Log into cPanel.
– Click the PHP Configuration button in the Software section.
– Select the version of PHP you want to use from the dropdown.
– Click the Update button to save your php configuration.
– 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.

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.

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.

 29 total views,  7 views today