Wednesday, 3 August 2011

PHP Inteview Questions

1) What exactly is PHP ?
PHP is also known as personal home page. PHP is used for producing dynamic WebPages. This language can be used for varied types of scripting such as server side scripting, standalone and for graphical applications. This is released under PHP license and is considered to be free software.

2) Describe about the security vulnerability of PHP?
According to the information obtained from the National vulnerability database, PHP has more than quarter of the software vulnerabilities discovered in 2008. Out of 33.33% software and scripts vulnerability PHP amounts to almost quarter of them. Register_globals a feature present in PHP is responsible for most of these vulnerabilities and now it is deprecated by PHP. Most of these security vulnerabilities occur due to poor programming techniques.

3) Explain about the data types in PHP?
PHP stores information numerical in a platform dependent range. Unsigned integers can be easily converted to signed integers. Decimal, octal, and hexadecimal notations can be easily assigned to integers. Floating point notation and two forms of scientific notation can be easily assigned to Real numbers. Zero is considered as false and all non zero numbers are considered as true.

4) Explain about Functions in PHP?
PHP has a large pool of functions and a huge number of them can be created by extensions. These functions can be defined at runtime by defining them inside the code. These functions have to be defined inside the parenthesis except for a class constructor function where there is no argument. Functions can be called or referenced by specifying their name.

5) Explain about objects in PHP?
In previous versions of PHP, object was fully copied before assigning a variable to a method. This problem was solved in new versions of PHP by the handle function. Many of the features present in PHP 5 are adopted from C++. Some of the features which are incorporated are restricted classes such as private and public, abstract and final classes, abstract and final methods, constructors and destructors with exception handling borrowed from C++.

6) What is a PHP accelerator?
PHP accelerator increases the speed of applications written in PHP. This boost of performance can be around 2-10 times. PHP accelerator increases the speed of the applications by decreasing parsing each and every time a PHP application runs. It depends upon factors such as time taken for execution of the PHP script and the actual percentage of the source code requested.

7) Explain about the $_GET variable of PHP?
This GET variable is executed when a request is sent from the user for information. This GET gets executed on the server and then information is sent back to the user. The information transmitted through this GET variable is viewable by everyone and is displayed in the address bar of the browser. A maximum of 100 characters is sent by the GET variable.

8) Explain about PHP cookies?
A Cookie is placed on the user desktop which uniquely identifies the user and every time a user views the webpage the same cookie is retrieved. With PHP a programmer can create and retrieve information simultaneously. The setcookie() function is used to create a cookie and PHP $_COOKIE variable helps the programmer to retrieve the cookie stored on the users computer. These both functions can function simultaneously.

9) Describe about PHP error and logging information?
Error handling function allows the user to detect the error and do necessary changes which paved the way for the error.
Logging functions pave the way for users to use log applications and send messages to system logs, email or for other specific purpose.
PHP has efficient error and logging constants to its credit. Some of them are E_ERROR, E_NOTICE, E_ALL, E_STRICT, etc.

10) Name and explain five of the PHP error constants?
Some of the five PHP error constants are E_ERROR, E_WARNING, E_PARSE, E_USER_WARNING, E_COMPILE_WARNING, etc
E_ERROR: -This error is displayed when there is fatal error which halts the execution of the script immediately.
E_WARNING: -This warns the programmer about the error but the execution of the script is not stopped.
E_PARSE: -These errors occur during compile time and these errors should only be generated by the parser.
E_USER_WARNING: -This warning error is generated by the user and is non fatal. This is set by the programmer using trigger_error().
E_COMPILE_WARNING: -this error is generated by the Zend scripting engine. This is a compile time non fatal error.

11) Explain about looping in PHP?
Looping is used to run the same script many number of times. Following statements are used in PHP for looping while, do...while, for each, and for statement.

12) Explain about require and include function?
Include function collects all the text in a defined specific file and copies the text information to the file which has the include function in it
Require function is similar to the include function except that it handles the error system in a different manner. Require function displays a fatal error and stops the execution of the script while the include function still executes the script.

13) Define about declare construct?
Declare construct allows you to define execution directives for a block set of code. This actually describes the way the code should perform. These declare construct can be set in such a manner that all the code is affected. The way the code performs can be set by the directive part which directly leads the code to follow.

14) What is the alternative structure for control structures?
The basic control structures are if, for, while, do while, for each and switch. If you are planning to use alternative structures then the closing braces should be changed to endif, endfor, endwhile, endswitch, and endforeach. Similarly the opening brace of the alternative syntax should be changed to (:) or colon. The alternative structure is applicable to else and elseif also.

15) Explain about switch statement in PHP?
Switch statement is executed line by line. PHP executes the statement only when the case statement matches the value of the switch expression. It does execute the statement until the end of the block till it finds the break statement. When the expression and statement matches themselves the code is executed.

16) Explain about PHP filter and why it should be used?
A PHP filter validates, filters according to the predefined statements from the programmer. It is very important for every programmer to validate user defines information as it can potential harm; PHP eliminated this risk by using PHP filter extension. This forms a good security practice for programmers.

17) What are the different filter functions used to filter a variable?
T filter a variable these are the following different functions used they are: -
1) Filter_var()
2) Filter_var_array()
3) Filter_input
4) Filter_input_array
 
18) What exactly is validating and sanitizing?
Validating and sanitizing are two different kinds of filters
Validating filters: - These filters are used to validate user sent information (input). Strict rules are applied for formatting such as URL or Email validating. It also sends the success type for a particular operation whether false or true.
Sanitizing filters: - These filters are used to allow or disallow specific characters present in a string. There are no restrictions on data format rules. This filter always returns the string.

0 comments:

Post a Comment

Popular Posts

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls