What is the difference between Primary Key and Unique key?

March 16, 2011 | Filed Under MySQL, PHP | Leave a Comment

Both Primary Key and Unique Key enforces uniqueness of the column on which they are defined. But by default Primary Key creates a Clustered Index on the column, where are Unique Key creates a Nonclustered Index by default. Another major difference is that, Primary Key doesn’t allow NULLs, but Unique Key allows one NULL only.

Article written by admin

What is the difference between $name and $$name?

March 16, 2011 | Filed Under PHP | Leave a Comment

$name is variable where as $$name is reference variable
like $name=Sadiq and $$name=Akhtar so $Sadiq value is Akhtar.

Article written by admin

what are the most common caching policy approaches ?

March 7, 2011 | Filed Under PHP | Leave a Comment

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

Article written by admin

What’s the difference between md5(), crc32() and sha1() crypto on PHP?

March 7, 2011 | Filed Under PHP | Leave a Comment

The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit md5() returns a 160 bit value. This is important when avoiding collisions.

Article written by admin

What Is a Persistent Cookie?

March 7, 2011 | Filed Under PHP | Leave a Comment

A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:

  • Temporary cookies can not be used for tracking long-term information.
  • Persistent cookies can be used for tracking long-term information.
  • Temporary cookies are safer because no programs other than the browser can access them.
  • Persistent cookies are less secure because users can open cookie files see the cookie values.
Article written by admin

How to handle drop down box change event without refreshing page?

March 7, 2011 | Filed Under PHP | Leave a Comment

We can change the contain of a drop down using AJAX without refresh the page. we can call a AJAX function on the onchange event of drop down.

Article written by admin

What is difference between require_once(), require(), include()? Because above three function usefully use to call a file in another file.

March 7, 2011 | Filed Under PHP | Leave a Comment

include()
————
It includes a spcified file.
It will produce a a warning if it fail to find the file and execute the remaining scripts

require
———–
It includes a spcified file.
It will produce a fatal error if it fail to find the file and stops the ececution

include_once()
——————-
It includes a spcified file.
a file has already been included, it will not be included again.
It will produce a a warning if it fail to find yhe file and execute the remaining scripts.

require_once()
———–
It includes a spcified file.
a file has already been included, it will not be included again.
It will produce a a fatal error if it fail to find the file and stops the ececution

Article written by admin

How to prevent web browser to image caching.

June 16, 2010 | Filed Under PHP | Comments Off

The simple way to prevent image caching is to append time stamp with the name on image.

Ex-<img src=’image.jpg?<?php echo time() ?>’ />

In the  above code browser understand a new image at every call. But HTML parser understands“image.jpg” for every call.

Article written by admin

How we can prevent Web browsers caching?

June 15, 2010 | Filed Under PHP | Comments Off
Using HTML meta tags: we can prevent Web browsers caching.
<meta content="Sun, 20 Fed 2000 01:11:11 GMT"
/>
<meta http-equiv="Pragma" content="no-cache" />
Here  free trial offer Meta tag tells the browser, cached copy of the page in back date.That means   browser should never cache the page.
But some browser does not support this approach .If you are working with php and include the header that has Meta definition.
For this case, use php Header function to produce the two meta tags above
<?php
header('Expires: Sun, 20 Fed 2000 01:11:11 GMT');
header('Pragma: no-cache');
?>
Or use
<?php
header('Expires: Sun, 20 Fed 2000 01:11:11 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
?>

In this case visitor will always see the latest contents.

Article written by admin

How can we increase Memory size in php during run time?

June 9, 2010 | Filed Under PHP | Comments Off

using ini_set(‘memory_limit’,’15M’); // now 15M space is  set during run time.

Article written by admin

How can we change the value of php.ini during runtime?

June 9, 2010 | Filed Under PHP | Comments Off

Using string 36 hour ong>ini_set ( string $varname , string $newvalue .
you can change

Article written by admin

How to increase Execution Time Limit in php Using ini_set()

June 9, 2010 | Filed Under PHP | Comments Off

To   increase the execution time for any php script simple use below code.

ini_set(‘max_execution_time’, 240); //240seconds = 4 minutes

Article written by admin

Q What are the two important changes in new versions of PHP that affect old code are ?

June 1, 2010 | Filed Under PHP | Comments Off

Ans: Following two of the most important  recent changes that affect old code are:
The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as global when used inside a function or met The following superglobal arrays were introduced in PHP » 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, $_REQUEST, and $_SESSION.The older $HTTP_*_VARS arrays, such as $HTTP_POST_VARS, still exist as they have since PHP 3. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

Article written by admin

Q How the method of our form is POST ?

June 1, 2010 | Filed Under PHP | Comments Off

Ans: If we used the method GET then our form information would live in the $_GET superglobal instead.
You may also use the $_REQUEST superglobal. if you do not care about the source of your request data. It contains of GET, POST and COOKIE data.

Article written by admin

Q What does htmlspecialchars() do ?

June 1, 2010 | Filed Under PHP | Comments Off

Ans: It makes sure any characters that are special in html are properly
encoded  so people can’t inject into commercial your page.

Article written by admin

Q How can we print the data from our form ?

June 1, 2010 | Filed Under PHP | Comments Off

Ans: Hi <?php echo htmlspecialchars($_POST['name']); ?>.
You are <?php echo (int)$_POST['age']; ?> years old.

A sample output of this script may be:

Hi Joe. You are 22 years old.

Article written by admin

Q What does a strpos() function do ?

June 1, 2010 | Filed Under PHP | Comments Off

Ans:It is a function built into PHP which searches a
string for another string.

Article written by admin

Q Which of the variable that PHP makes automatically available to you ?

June 1, 2010 | Filed Under PHP | Comments Off

Ans:$_SERVER

Article written by admin

Q How can we display $_SERVER variable ?

May 31, 2010 | Filed Under PHP | Comments Off

Ans: To display this variable-

Example:-  Printing a ws variable (Array element):-

<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
A sample output of this script may be:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Article written by admin

Q Where the all webserver information is stored in PHP ?

May 31, 2010 | Filed Under PHP | Comments Off

Ans: $_SERVER is a PHP variable that contains all web server information It is known as a superglobal.

Article written by admin

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker