Suscriber with us



Receive HTML?

Syndicate

php interview questions part2 PDF Print E-mail

1.What is the output here?

<?php
session_start();
$_SESSION["var"] = NULL;
echo $var = "www.phpguru.biz";
?>

The output :
www.w3answers.com and warning as below

2.Which function in PHPgives us absolute path of a file on the server?

class="MsoNormal">

Ans: getcwd()

<?php
$p = getcwd();
echo $p;
?>

here I have stored my files under httdocs (using php5,i haven't checked under php4) so I get the output as C:\apache2triad\htdocs
you may get your path information while runnings the above code. :)

3.How can we extract string “www.phpguru.biz” from a string Mail to:"www.lalit.com" using regular expresstion of PHP?

Answer:

<?php
$w3 = "mailto:
www.lalit.com";
preg_match('|.*@([^?]*)|', $w3, $w3output);
echo $w3output[1];
?>

4.Which is faster mysql_unbuffered_query or mysql query?

when we do the select queries that retrieve large data sets from MySQL, mysql_unbuffered_query in PHP is likely to give better performance than mysql_query.

PHP manual says,it “sends a SQL query query to MySQL, without fetching and buffering the result rows automatically”.

5.Why should we use object orient concept on PHP?

1. Object oriented PHP code is much more reusable because by its' very nature, it is modular.

2. Object oriented PHP is easier to update. Again, because PHP code is organised into objects.

3. Object oriented PHP makes team programming much easier to manage.

4. Object oriented PHP makes larger projects much easier to manage.

5. Object oriented PHP makes creating code libraries much easier.

6. Knowing Object oriented PHP will make working with many opensource PHP libraries much easier. For example: projects like PEAR and the Zend Framework are built using Object oriented PHP.

7. Object oriented PHP programmers typically make more money and will be able to work on more projects.

8. Since object oriented concepts are the same in all Object oriented languages, once you learn Object oriented programing in PHP, you will also have a good understanding of several other languages including:

a. rina
b. Java
c. C#
d. Actionscript
…among several other languages.

6.What is the difference between $message and $$message?

$message is a simple variable whereas $$message is a variable's variable,which means
value of the variable. Example:
$user = 'bob'

is equivalent to

$message = 'user';
$$message = 'bob';

7.How to capture content from the output buffer? Or give me an example
for output caching in PHP?

<?php

ob_start(); // start an output buffer

echo ‘This text is from the
www.phpguru.biz buffer*******<br />’; // output that will be stored in the buffer

$w3buffer = ob_get_contents(); // store buffer content in $w3buffer variable

ob_end_clean(); // stop and clean the output buffer

echo ‘This is not from the
www.phpguru.biz buffer!!!!!!!!<br />’;

echo $w3buffer;

?>

O/p
*****

This is not from the
www.phpguru.biz buffer
This text is from the
www.phpguru.biz buffer

8.What are the most common caching policy approaches?

1)Time triggered caching (expiry timestamp).

2)Content change triggered caching (sensitive content has changed, so cache must be updated).

3)Manually triggered caching (manually inform the application that information is outdated, and force a new cache creation).

9.What is the php solution to dynamic caching?

PHP offers an extremely simple solution to dynamic caching in the form of output buffering.

10.How do I prevent web browsers caching in page php?

<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Pragma: no-cache');
?>





Digg!Del.icio.us!Google!Live!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Yahoo!Free social bookmarking plugins and extensions for Joomla! websites!
Last Updated ( Thursday, 13 March 2008 )
 
< Prev   Next >

Download Utility

XAMPP
WAMP
EditPlus
Zend Studio

Polls

Which is the best Scripting language?