• LOGIN
  • No products in the cart.

PHP Interview Questions

What is PHP?

PHP is a server side scripting language commonly used for web applications. PHP has many frameworks and cms for creating websites.Even a non technical person can cretae sites using its CMS.WordPress,osCommerce are the famus CMS of php.It is also an object oriented programming language like java,C-sharp etc.It is very eazy for learning.

How to include a file to a php page?

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

What is the main difference between PHP 4 and PHP 5?

PHP 5 presents many additional OOP (Object Oriented Programming) features.

PHP Online Training

Explain how to submit form without a submit button?

We can achieve the above task by using JavaScript code linked to an event trigger of any form field and call the document.form.submit() function in JavaScript code.

Explain the different types of errors in PHP?

Notices, Warnings and Fatal errors are the types of errors in PHP
Notices:
Notices represents non-critical errors, i.e. accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all but whenever required, you can change this default behavior.

Warnings:
Warnings are more serious errors but they do not result in script termination. i.e calling include() a file which does not exist. By default, these errors are displayed to the user.

Fatal errors:
Fatal errors are critical errors i.e. calling a non-existent function or class. These errors cause the immediate termination of the script.

What is MIME?

MIME – Multi-purpose Internet Mail Extensions.

MIME types represents a standard way of classifying file types over Internet.

Web servers and browsers have a list of MIME types, which facilitates files transfer of the same type in the same way, irrespective of operating system they are working in.

A MIME type has two parts: a type and a subtype. They are separated by a slash (/).

MIME type for Microsoft Word files is application and the subtype is msword, i.e. application/msword.

What is the use of PEAR in php?

PEAR is known as PHP Extension and Application Repository. It provides structured library to the PHP users and also gives provision for package maintenance.

What are the steps involved to run PHP?

The steps which are involved and required to run PHP is as follows:
1. Set up the web environment.
2. Set up the web servers. There are many web servers that are available and the mostly used is Apaches which automatically remains installed with linux distribution and on windows it is easy to install. There are other servers like IIS (Internet information server) provided by Microsoft can be used to set up the web environment.
3. Install the web server and PHP
4. Update and administer the system for changes.

What’s the difference between include and require?

If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

Differences between GET and POST methods ?

We can send 1024 bytes using GET method but POST method can transfer large amount of data and POST is the secure method than GET method .

What is the use of mysql_real_escape_string() function?

It is used to escapes special characters in a string for use in an SQL statement

What is the use of header() function in php ?

The header() function sends a raw HTTP header to a client browser.Remember that this function must be called before sending the actual out put.For example, You do not print any HTML element before using this function.

What is the use of isset() in php?

This function is used to determine if a variable is set and is not NULL

How to get the value of current session id?

session_id() function returns the session id for the current session.

What is sql injection ?

SQL injection is a malicious code injection technique.It exploiting SQL vulnerabilities in Web applications

How is it possible to set an infinite execution time for PHP script?

The set_time_limit(0) added at the beginning of a script sets to infinite the time of execution to not have the PHP error ‘maximum execution time exceeded’.It is also possible to specify this in the php.ini file.

How can we access the data sent through the URL with the POST method?

To access the data sent this way, you use the $_POST array.
Imagine you have a form field called ‘var’ on the form, when the user clicks submit to the post form, you can then access the value like this:
$_POST[“var”];

What does the unset() function means?

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

How can you pass a variable by reference?

To be able to pass a variable by reference, we use an ampersand in front of it, as follows $var1 = &$var2

When a conditional statement is ended with an endif?

When the original if was followed by : and then the code block without braces.

What does accessing a class via :: means?

is used to access static methods that do not require object initialization.

When sessions ends?

Sessions automatically ends when the PHP script finishs executing, but can be manually ended using the session_write_close().

Is it possible to protect special characters in a query string?

Yes, we use the urlencode() function to be able to protect special characters.

How can you pass a variable by reference?

To be able to pass a variable by reference, we use an ampersand in front of it, as follows $var1 = &$var2

How to initiate a session in PHP?

The use of the function session_start() lets us activating a session.

November 27, 2019
GoLogica Technologies Private Limited  © 2019. All rights reserved.