Friday, April 4, 2014

couch mode print story

PHP Interview Questions and Answers


1. What's PHP ?

The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic
content that interacts with databases. PHP is basically used for developing web based software applications.
PHP development began in 1994 when the Danish/Greenlandic programmer Rasmus Lerdorf initially created
a set of Perl scripts he called "Personal Home Page Tools" to maintain his personal homepage. Marco Tabini is the funder an publisher of PHP|architech.


2. What is Full form of PHP ? Who is the father or inventor of PHP ?

Rasmus Lerdorf is known as the father of PHP that started development of PHP in 1994 for their own Personal Home Page (PHP) and they released PHP/FI (Forms Interpreter) version 1.0 publicly on 8 June 1995 But in 1997 two Israeli developers named Zeev Suraski and Andi Gutmans rewrote the parser that formed the base of PHP 3 and then changed the language's name to the PHP: Hypertext Preprocessor.


3. What Is a Session?

A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.


4. What are the method available in form submitting?

GET and POST.


5. How can we submit from without a submit button?

The main idea behind this to use a simple JavaScript code linked to an event trigger of any form field. In the
JavaScript code, we can call the document.form.submit(); function to submit the form.


6. 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.


7. 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.


8. Differences between GET and POST methods ?

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


9. What are the different functions in sorting an array?

asort()
arsort()
ksort()
krsort()
uksort()
sort()
natsort()
rsort()


10. How we can retrieve the data in the result set of MySQL using PHP?

1. mysql_fetch_row
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc


11. Explain include(), include_once, require() and require_once.

include()
The include() function takes all the content in a specified file and includes it in the current file. If an error occurs, the include() function generates a warning, but the script will continue execution.
include_once()
File will not be included more than once. If we want to include a file once only and further calling of the file
will be ignored then we have to use the PHP function include_once().
require()
The require() function is identical to include(), except that it handles errors differently. The require() generates
a fatal error, and the script will stop.
require_once()
The required file is called only once when a page is open and further calling of the file will be ignored.


12. How can I execute a PHP script using command line?

Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the
command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program. Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.


13. Difference between mysql_connect and mysql_pconnect?

There is a good page in the php manual on the subject, in short mysql_pconnect() makes a persistent
connection to the database which means a SQL link that do not close when the execution of your script ends.
mysql_connect()provides only for the databasenewconnection while using mysql_pconnect , the function
would first try to find a (persistent) link that's already open with the same host, username and password. If
one is found, an identifier for it will be returned instead of opening a new connection... the connection to the
SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for
future use.


14. What is the difference between $var and $$var?

They are both variables. But $var is a variable with a fixed name. $$var is a variable who's name is stored in
$var. For example, if $var contains "message", $$var is the same as $message.


15. What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system.
unset() makes a variable undefined.


16. What is the difference between PHP4 and PHP5?

PHP4 cannot support oops concepts and Zend engine 1 is used.
PHP5 supports oops concepts and Zend engine 2 is used. Error supporting is increased in PHP5. XML and
SQLLite will is increased in PHP5.


17. What are the differences between mysql_fetch_array(), mysql_fetch_object(),

mysql_fetch_row()?
mysql_fetch_array:
Fetch a result row as an associative array and a numeric array.
mysql_fetch_object:
Returns an object with properties that correspond to the fetched row and moves the internal data pointer
ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more
rows.
mysql_fetch_row():
Fetches one row of data from the result associated with the specified result identifier. The row is returned as
an array. Each result column is stored in an array offset, starting at offset 0.


18. How to delete a file from the system?

Unlink() deletes the given file from the file system.


19. what is sql injection ?

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


20. What is PEAR?

PEAR is a framework and distribution system for reusable PHP components.The project seeks to provide a
structured library of code, maintain a system for distributing code and for managing code packages, and
promote a standard coding style.PEAR is broken into three classes: PEAR Core Components, PEAR Packages, and PECL Packages. The Core Components include the base classes of PEAR and PEAR_Error, along with database, HTTP, logging, and e-mailing functions. The PEAR Packages include functionality providing for authentication, networking, and file system features, as well as tools for working with XML and HTML templates.

Written




0 comments:

Post a Comment