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.
What is the difference between $name and $$name?
$name is variable where as $$name is reference variable
like $name=Sadiq and $$name=Akhtar so $Sadiq value is Akhtar.
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).
What’s the difference between md5(), crc32() and sha1() crypto on PHP?
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.
What Is a Persistent Cookie?
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.
How to handle drop down box change event without refreshing page?
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.
What is difference between require_once(), require(), include()? Because above three function usefully use to call a file in another file.
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
How to prevent web browser to image caching.
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.
How we can prevent Web browsers caching?
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.
How can we increase Memory size in php during run time?
using ini_set(‘memory_limit’,’15M’); // now 15M space is set during run time.
How can we change the value of php.ini during runtime?
Using string 36 hour ong>ini_set ( string $varname , string $newvalue .
you can change
How to increase Execution Time Limit in php Using ini_set()
To increase the execution time for any php script simple use below code.
ini_set(‘max_execution_time’, 240); //240seconds = 4 minutes
Q What are the two important changes in new versions of PHP that affect old code are ?
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.
Q How the method of our form is POST ?
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.
Q What does htmlspecialchars() do ?
Ans: It makes sure any characters that are special in html are properly
encoded so people can’t inject into commercial your page.
Q How can we print the data from our form ?
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.
Q What does a strpos() function do ?
Ans:It is a function built into PHP which searches a
string for another string.
Q How can we display $_SERVER variable ?
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)
Q Where the all webserver information is stored in PHP ?
Ans: $_SERVER is a PHP variable that contains all web server information It is known as a superglobal.
