<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>blazt.com &#187; PHP Interview Question &amp; Answer</title>
	<atom:link href="http://merlyscaria.wordpress.com/category/php-interview-question-answer/feed/" rel="self" type="application/rss+xml" />
	<link>http://merlyscaria.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 15 Jul 2009 05:33:42 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='merlyscaria.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/c31d1c09edbc8e5b7c0729dceed093df?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>blazt.com &#187; PHP Interview Question &amp; Answer</title>
		<link>http://merlyscaria.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://merlyscaria.wordpress.com/osd.xml" title="blazt.com" />
		<item>
		<title>PHP Interview Question &amp; Answer</title>
		<link>http://merlyscaria.wordpress.com/2008/04/30/php-interview-question-answer/</link>
		<comments>http://merlyscaria.wordpress.com/2008/04/30/php-interview-question-answer/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 06:14:49 +0000</pubDate>
		<dc:creator>merly</dc:creator>
				<category><![CDATA[PHP Interview Question & Answer]]></category>
		<category><![CDATA[basics of php]]></category>
		<category><![CDATA[freqently asked questions in php]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php interview questions]]></category>
		<category><![CDATA[php questions and answers]]></category>

		<guid isPermaLink="false">http://merlyscaria.wordpress.com/?p=37</guid>
		<description><![CDATA[1. What are the differences between GET and POST methods in form submitting, give
the case where we can use get and we can use post methods?
Answer:
On the server side, the main difference between GET and POST is where the
submitted is stored. The $_GET array stores data submitted by the GET method.
The $_POST array stores data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=merlyscaria.wordpress.com&blog=2300345&post=37&subd=merlyscaria&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>1. What are the differences between GET and POST methods in form submitting, give<br />
the case where we can use get and we can use post methods?</strong><br />
Answer:<br />
On the server side, the main difference between GET and POST is where the<br />
submitted is stored. The $_GET array stores data submitted by the GET method.<br />
The $_POST array stores data submitted by the POST method.<br />
On the browser side, the difference is that data submitted by the GET method will<br />
be displayed in the browser&#8217;s address field. Data submitted by the POST method<br />
will not be displayed anywhere on the browser.<br />
GET method is mostly used for submitting a small amount and less sensitive data.<br />
POST method is mostly used for submitting a large amount or sensitive data.</p>
<p><strong> 2. Who is the father of php and explain the changes in php versions?</strong><br />
Answer:<br />
Rasmus Lerdorf for version changes go to http://php.net/<br />
Marco Tabini is the founder and publisher of php|architect.<br />
<strong>3. How can we submit from without a submit button?</strong><br />
Answer:<br />
We can use a simple JavaScript code linked to an event trigger of any form field.<br />
In the JavaScript code, we can call the document.form.submit() function to submit<br />
the form. For example:<br />
<strong>4. How many ways we can retrieve the date in result set of mysql Using php?</strong><br />
Answer:<br />
As individual objects so single record or as a set or arrays.<br />
<strong> 5. What is the difference between mysql_fetch_object and mysql_fetch_array?</strong><br />
Answer:<br />
MySQL fetch object will collect first single matching record where<br />
mysql_fetch_array will collect all matching records from the table in an array.<br />
<strong> 6. What is the difference between $message and $$message?</strong><br />
Answer:<br />
They are both variables. But $message is a variable with a fixed name. $$message is<br />
a variable who&#8217;s name is stored in $message. For example, if $message contains<br />
&#8220;var&#8221;, $$message is the same as $var.<br />
<strong> 7. How can we extract string &#8216;abc.com &#8216; from a string</strong><br />
&#8216;http://info@a&#8230;&#8217; using regular _expression of php?<br />
Answer:<br />
We can use the preg_match() function with &#8220;/.*@(.*)$/&#8221; as<br />
the regular expression pattern. For example:<br />
preg_match(&#8220;/.*@(.*)$/&#8221;,&#8221;http://info@abc.com&#8221;,$data);<br />
echo $data[1];<br />
<strong> 8. How can we create a database using php and mysql?</strong><br />
Answer:<br />
PHP: mysql_create_db()<br />
Mysql: create database;<br />
<strong>9. What are the differences between require and include, include_once?</strong><br />
Answer:<br />
File will not be included more than once. If we want to include a file once only and<br />
further calling of the file will be ignored then we have to use the PHP function<br />
include_once(). This will prevent problems with function redefinitions, variable<br />
value reassignments, etc.<br />
<strong>10. Can we use include (&#8220;abc.php&#8221;) two times in a php page &#8220;makeit.php&#8221;?</strong><br />
Answer:<br />
Yes we can include..<br />
<strong>11. What are the different tables present in mysql, which type of table is generated when</strong><br />
we are creating a table in the following<br />
syntax: create table employee(eno int(2),ename varchar(10)) ?<br />
Answer:<br />
Total 5 types of tables we can create<br />
1. MyISAM<br />
2. Heap<br />
3. Merge<br />
4. InnoDB<br />
5. ISAM<br />
6. BDB<br />
MyISAM is the default storage engine as of MySQL 3.23.<br />
<strong>12. Functions in IMAP, POP3 AND LDAP?</strong><br />
Answer:<br />
Please visit:<br />
http://fi2.php.net/imap<br />
http://uk2.php.net/ldap<br />
<strong>13. How can I execute a php script using command line?</strong><br />
Answer:<br />
Just run the PHP CLI (Command Line Interface) program and provide the PHP<br />
script file name as the command line argument. For example, &#8220;php myScript.php&#8221;,<br />
assuming &#8220;php&#8221; is the command to invoke the CLI program.<br />
Be aware that if your PHP script was written for the Web CGI interface, it may not<br />
execute properly in command line environment.<br />
<strong></strong></p>
<p><strong>14. Suppose your ZEND engine supports the mode &lt;? ?&gt; Then how can u configure your<br />
php ZEND engine to support &lt;?php ?&gt; mode ?</strong><br />
Answer:<br />
If you change the line: short_open_tag = off in php.ini file. Then your php ZEND<br />
engine support only &lt;?php ?&gt; mode.<br />
15. Shopping cart online validation i.e. how can we configure the paypals?<br />
<strong>16. What is meant by nl2br()?</strong><br />
Answer:<br />
nl2br &#8212; Inserts HTML line breaks before all newlines in a string<br />
string nl2br (string);<br />
Returns string with &#8216;&lt;br /&gt;&#8217; inserted before all newlines.<br />
For example: echo nl2br(&#8220;god bless\n you&#8221;) will output &#8220;god bless<br />
\n you&#8221; to your browser.<br />
<strong>17. Draw the architecture of ZEND engine?</strong></p>
<p><strong></strong><strong>18. What are the current versions of apache, php, and mysql?</strong><br />
Answer:<br />
PHP: php5.1.2<br />
MySQL: MySQL 5.1<br />
Apache: Apache 2.1<br />
<strong>19. What are the reasons for selecting lamp (Linux, apache, mysql, php) instead of<br />
combination of other software programs, servers and operating systems?</strong><br />
Answer:<br />
All of those are open source resource. Security of linux is very very more than<br />
windows. Apache is a better server that IIS both in functionality and security.<br />
Mysql is world most popular open source database. Php is more faster that asp or<br />
any other scripting language.<br />
<strong>20. How can we encrypt and decrypt a data present in a mysql table using mysql?</strong><br />
Answer:<br />
AES_ENCRYPT () and AES_DECRYPT ()<br />
<strong>21. How can we encrypt the username and password using php?</strong><br />
Answer:<br />
You can encrypt a password with the following Mysql&gt;SET<br />
PASSWORD=PASSWORD(&#8220;Password&#8221;);<br />
We can encode data using base64_encode($string) and can decode using<br />
base64_decode($string);</p>
<p><strong> 22. What are the features and advantages of OBJECT ORIENTED PROGRAMMING?</strong><br />
Answer:<br />
One of the main advantages of OO programming is its ease of modification; objects<br />
can easily be modified and added to a system there by reducing maintenance costs.<br />
OO programming is also considered to be better at modeling the real world than is<br />
procedural programming. It allows for more complicated and flexible interactions.<br />
OO systems are also easier for non-technical personnel to understand and easier for<br />
them to participate in the maintenance and enhancement of a system because it<br />
appeals to natural human cognition patterns.<br />
For some systems, an OO approach can speed development time since many objects<br />
are standard across systems and can be reused. Components that manage dates,<br />
shipping, shopping carts, etc. can be purchased and easily modified for a specific<br />
system.</p>
<p><strong> 23. What are the differences between PROCEDURE ORIENTED LANGUAGES<br />
AND OBJECT ORIENTED LANGUAGES?</strong><br />
Answer:<br />
Traditional programming has the following characteristics:<br />
Functions are written sequentially, so that a change in programming can affect any<br />
code that follows it.</p>
<p>If a function is used multiple times in a system (i.e., a piece of code that manages the<br />
date), it is often simply cut and pasted into each program (i.e., a change log, order<br />
function, fulfillment system, etc). If a date change is needed (i.e., Y2K when the code<br />
needed to be changed to handle four numerical digits instead of two), all these pieces<br />
of code must be found, modified, and tested.</p>
<p>Code (sequences of computer instructions) and data (information on which the<br />
instructions operates on) are kept separate. Multiple sets of code can access and<br />
modify one set of data. One set of code may rely on data in multiple places. Multiple<br />
sets of code and data are required to work together. Changes made to any of the<br />
code sets and data sets can cause problems through out the system.</p>
<p>Object-Oriented programming takes a radically different approach:<br />
Code and data are merged into one indivisible item – an object (the term<br />
“component” has also been used to describe an object.) An object is an abstraction<br />
of a set of real-world things (for example, an object may be created around “date”)<br />
The object would contain all information and functionality for that thing (A dateobject it may contain labels like January, February, Tuesday, Wednesday. It may<br />
contain functionality that manages leap years, determines if it is a business day or a<br />
holiday, etc., See Fig. 1). Ideally, information about a particular thing should reside<br />
in only one place in a system. The information within an object is encapsulated (or<br />
hidden) from the rest of the system.<br />
A system is composed of multiple objects (i.e., date function, reports, order<br />
processing, etc., See Fig 2). When one object needs information from another object,<br />
a request is sent asking for specific information. (for example, a report object may<br />
need to know what today’s date is and will send a request to the date object) These<br />
requests are called messages and each object has an interface that manages<br />
messages.<br />
OO programming languages include features such as “class”, “instance”,<br />
“inheritance”, and “polymorphism” that increase the power and flexibility of an<br />
object.</p>
<p><strong>24. What is the use of friend function?</strong><br />
Answer:<br />
Friend functions<br />
Sometimes a function is best shared among a number of different classes. Such<br />
functions can be declared either as member functions of one class or as global<br />
functions. In either case they can be set to be friends of other classes, by using a<br />
friend specifier in the class that is admitting them. Such functions can use all<br />
attributes of the class whichnames them as a friend, as if they were themselves<br />
members of that class.</p>
<p><strong>25. What are the different types of errors in php?</strong><br />
Answer:<br />
Three are three types of errors:</p>
<p>1. Notices: These are trivial, non-critical errors that PHP encounters while<br />
executing a script &#8211; for example, accessing a variable that has not yet been defined.<br />
By default, such errors are not displayed to the user at all &#8211; although, as you will see,<br />
you can change this default behaviour.<br />
2. Warnings: These are more serious errors &#8211; for example, attempting to include() a<br />
file which does not exist. By default, these errors are displayed to the user, but they<br />
do not result in script termination.<br />
3. Fatal errors: These are critical errors &#8211; for example, instantiating an object of a<br />
non-existent class, or calling a non-existent function. These errors cause the<br />
immediate termination of the script, and PHP&#8217;s default behaviour is to display them<br />
to the user when they take place.</p>
<p><strong>26. How can we convert asp pages to php pages?</strong><br />
Answer:<br />
You can download asp2php front-end application from the site<br />
http://asp2php.naken.cc.</p>
<p><strong>27.How can we get second of the current time using date function?</strong><br />
Answer:<br />
$second = date(“s”);</p>
<p><strong>28. What is the difference between the functions unlink and unset?</strong><br />
Answer:<br />
unlink() deletes the given file from the file system.<br />
unset() makes a variable undefined.</p>
<p><strong>29.   How can we register the variables into a session?</strong><br />
Answer:<br />
We can use the session_register ($ur_session_var) function.</p>
<p>30.  <strong> What is the difference between char and varchar data types?</strong><br />
Answer:<br />
char(M) M bytes 0&lt;=M&lt;=255<br />
varchar(M) L+1 bytes where L&lt;=M &amp; 0&lt;=M&lt;=255<br />
i.e.; char data type allocate memory statically<br />
and varchar data type allocate memory dynamically</p>
<p><strong>31.    What is the functionality of md5 function in php?</strong><br />
Answer:<br />
string md5(string)<br />
Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number.<br />
We can use it to generate keys, which we use to identify users etc. If we add random<br />
no techniques to it the md5 generated now will be totally different for the same<br />
string we are using..</p>
<p><strong>32. How can we know the number of days between two given dates using mysql?</strong><br />
Answer:<br />
select DIFFDATE( NOW(), ‘yyyy-mm-dd’ );</p>
<p><strong>33. </strong> <strong>What are the differences between drop a table and truncate a table?</strong><br />
Answer:<br />
Delete a Table or DatabaseTo delete a table (the table structure, attributes, and<br />
indexes will also be deleted).<br />
What if we only want to get rid of the data inside a table, and not the table itself?<br />
Use the TRUNCATE TABLE command (deletes only the data inside the table).</p>
<p><strong>34.     What are the different ways to login to a remote server? Explain the means,<br />
advantages and disadvantages?</strong><br />
Answer:<br />
There is at least 3 ways to logon to a remote server:<br />
Use ssh or telnet if you concern with security<br />
You can also use rlogin to logon to a remote server.</p>
<p><strong>35.    How would you backup and restore a big MySQL database? What are the advantages<br />
of the approach which you have taken over the others?</strong><br />
Use the mysqldump command.<br />
If you have Telnet/SSH access to your MySQL server, log in and issue the following<br />
command for each database you want to back up:<br />
shell&gt; mysqldump -u user -ppassword &#8211;opt -full database_name &gt; backupfile.sql</p>
<p>Then move the resulting file(s) to your preferred backup areas. If you require more<br />
information on the mysqldump command, then simply check out this<br />
URL:www.mysql.com/documentation/mysql<br />
Copy all the relevant table files.<br />
If the server isn&#8217;t updating anything (or you&#8217;ve deliberately killed mysqld for this<br />
purpose) then you can copy all the files with the following extensions in your<br />
MySQL data directory:<br />
*.frm<br />
*.myd<br />
*.myi<br />
Make sure you restart the MySQL daemon once you finish copying and<br />
downloading the files to your preferred backup areas.<br />
TIP: once you&#8217;ve completed the backup, restart MySQL with the &#8211;log-update<br />
switch. This will allow you to keep track of all modifications done in the MySQL<br />
tables since your last &#8216;dump&#8217;.<br />
To restore your dumps, you should either restore to an existing database or create a<br />
new database using<br />
shell&gt; mysqladmin create database_name<br />
then issue the following command :<br />
shell&gt; mysql -u user -ppassword database_name &lt; backup-file.sql<br />
If you don&#8217;t have access to Telnet/SSH and you&#8217;re unable to do backups using the<br />
methods described above, you should ask your host if it is possible for them to do a<br />
backup for you and put the backups in a separate directory so that you can easily<br />
FTP your backups to your selected backup areas. Otherwise, if you have access to<br />
phpMyAdmin, you can use the following procedure:<br />
Access phpMyAdmin, and select the database you wish to &#8216;dump&#8217; (backup).<br />
Scroll down and you will see a bulleted point saying: &#8220;View dump (schema) of<br />
database&#8221; along with some radio and check boxes. Choose &#8216;Structure and data&#8217;,<br />
then click on &#8216;Add Drop Table&#8217; and &#8216;Send&#8217; and click &#8216;Go&#8217;. This will save the &#8216;dump&#8217;<br />
to your hard drive.<br />
To restore a dump using phpMyAdmin, simply insert the file in the correct place<br />
once you have chosen the correct database by doing the following:<br />
Choose the database you will insert your data into, or create a new database.<br />
Insert the appropriate SQL queries you already have, or just paste the name of<br />
the .sql file you have on your hard drive into the text box under &#8216;Location of the<br />
textfile&#8217;, and fire away!<br />
Tip : use a crontab job to schedule backups periodically.<br />
The advantages of this approach is the backup is only a file consisting of SQL query.<br />
So that needs minimum spaces to backup a large database.<br />
<strong>36.    For the database from the previous question, please give an SQL query which returns<br />
the invoice number of all invoices which contain the article with the number &#8220;1234&#8243;. The<br />
query should be able to run under a MySQL 4.0 database.</strong><br />
Answer:<br />
Select invoceNo from invoice where article_id=1234;</p>
<p><strong>37.    What is meant by PEAR in php?</strong><br />
Answer:<br />
PEAR is short for “PHP Extension and Application Repository” and is pronounced<br />
just like the fruit. The purpose of PEAR is to provide:<br />
A structured library of open-sourced code for PHP users<br />
A system for code distribution and package maintenance<br />
A standard style for code written in PHP<br />
The PHP Foundation Classes (PFC),<br />
The PHP Extension Community Library (PECL),<br />
A web site, mailing lists and download mirrors to support the PHP/PEAR<br />
community<br />
PEAR is a community-driven project with the PEAR Group as the governing body.<br />
The project has been founded by Stig S. Bakken in 1999 and quite a lot of people<br />
have joined the project since then.<br />
http://pear.php.net/manual/en/introduction.php</p>
<p><strong>38   How many ways we can give the output to a browser?</strong><br />
Answer:<br />
HTML output<br />
PHP, ASP, JSP, Servlet Function<br />
Script Language output Function<br />
Different Type of embedded Package to output to a browser<br />
<strong>39. How can we know that a session is started or not?</strong><br />
Answer:<br />
a session starts by session_start()function.<br />
this session_start() is always declared in header portion.it always declares first.then<br />
we write session_register().</p>
<p><strong>40. What is the default session time in php and how can I change it?</strong><br />
Answer:<br />
The default session time in php is until closing of browser</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/merlyscaria.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/merlyscaria.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/merlyscaria.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/merlyscaria.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/merlyscaria.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/merlyscaria.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/merlyscaria.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/merlyscaria.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/merlyscaria.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/merlyscaria.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/merlyscaria.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/merlyscaria.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=merlyscaria.wordpress.com&blog=2300345&post=37&subd=merlyscaria&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://merlyscaria.wordpress.com/2008/04/30/php-interview-question-answer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/669e31be3d236b5be22af924547d7b5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">merly</media:title>
		</media:content>
	</item>
	</channel>
</rss>