Category Archives: PHP Interview Questions



How to capture content from the output buffer ? or Give me an example for Output caching in php?

ob_start(); // start an output buffer
echo ‘This text is from the w3answers buffer*******
’; // 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 w3answers buffer!!!!!!!!
’;
echo $w3buffer;
?>
O/p

How to capture content from the output buffer ? or Give me an example for Output caching in php?

ob_start(); // start an output buffer
echo ‘This text is from the w3answers buffer*******
’; // 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 w3answers buffer!!!!!!!!
’;
echo $w3buffer;
?>

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’;

what is the php solution to dynamic caching ?

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

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).
* Add new comment
* Back to Top

What Are PHP Arrays?

PHP arrays are associative arrays with a little extra machinery thrown in.
The associative part means that arrays store element
values in association with key values rather than in a
strict linear index order. (If you have seen arrays in other programming languages, they are likely to have been vector arrays rather
than associative arrays.) If you store an element in an array,
in association with a key,all you need to retrieve it later from
that array is the key value. For example, storage is as

Are php strings immutable ?

PHP strings can be changed, but the most common practice seems to be to treat strings as immutable.Strings can be changed by treating them as character arrays and assigning directly into them, like this:
$my_string = “abcdefg”;
$my_string[5] = “X”;
print($my_string . “
”);
which will give the browser output:
abcdeXg
?>

what is Memcache?

Memcache is a technology which caches objects in memory where your web application can get to them really fast. It is used by sites such as Digg.com, Facebook.com and NowPublic.com and is widely recognized as an essential ingredient in scaling any LAMP application to handle enormous traffic.

How do I prevent Web browsers caching a page in php?

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

What is the process that takes place when you upload a file in php?

There are two basic things covered here.
The form that will be used to post the file data to and the actual program that does the uploading. Further we will discuss the method that PHP itself suggests for uploading files.
Process 1 HTML PART

* Add new comment
* Read more
* Back to Top

Will persistent connection work in the CGI version of php ? mysql_connect() vs mysql_pconnect()?

Persistent database connections work only in the module installation of PHP.
If you ask for a persistent connection in the CGI version,
you will simply get a regular connection.

what are the ‘function problems’ you have met in php?

1)Call to undefined function we_w3answers()
*****************************************
PHP is trying to call the function we_w3answers(), which has not been
because you misspelled the name of a function (built-in or user-defined)
simply omitted the function definition. If you use include/require
functions, make sure that you are loading the appropriate files.
2)Call to undefined function array()
***********************************
* Add new comment
* Read more
* Back to Top

Explain Parse Errors ? what are the most common causes of parse errors ?

The most common category of error arises from mistyped
or syntactically incorrect PHP code, which confuses the PHP parsing engine.
1)The missing semicolon
***********************
If each PHP instruction is not duly finished off with a semicolon,
a parse error will result. In this sample fragment, the first line lacks a semicolon and, therefore, the variable assignment is never completed.
What we have here is

$Problem = “a silly misunderstanding”
echo $Problem;

* Add new comment
* Read more
* Back to Top

List out some session functions in php?

session_save_path — Get and/or set the current session save path
session_is_registered — Find out whether a global variable is registered in a session
* Add new comment
* Read more
* Back to Top

What is meant by Persistent Database Connections?

Persistent connections are links that do not close when the execution of your script ends.
* Add new comment
* Read more
* Back to Top