Showing posts with label functions. Show all posts
Showing posts with label functions. Show all posts

Friday, April 9, 2010

question about array sorts in php

Question: What are all the array sorts in php?

Answer: The following are the array sort functions

sort()
asort()
arsort()
krsort()
usort()
ksort()
natcasesort()
rsort()
shuffle()
array_multisort()
uasort()
uksort()
natsort()

Friday, April 2, 2010

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.

number of days between two given dates using PHP?

Answer

$date1 = date('Y-m-d');
$date2 = '2006-07-01';
$days = (strtotime() - strtotime()) / (60 * 60 * 24);
echo "Number of days since '2006-07-01': $days";

what is cookies in php

Answer

Say simply - - Cookies are mechanism of storing temporary datas in browser memory

what is session

Answer
======

In short - Session is mechanism of storing temporary values in the server

Php.net explanation

Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.

A visitor accessing your web site is assigned a unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL.

Thursday, April 1, 2010

Difference between include_once and require_once in php

Include_once will include a file only one time. If we call it again it will not include.

The difference is reqire_once will through a fatal error if you include a same file again

Difference between include and require in php

In php require statement through fatal error if the file is not in the given path. So the script execution will stop.

The include will show just warnings. So the next line will be executed .


Identifying the number of parameters passed to a function?

Answer:

We can use - func_num_args()

This function can return the number of argument passed to the function

small example

function test()
{
$numargs = func_num_args();
echo
"Number of passed arguments: $numargs\n";
}

test(1, 2, 3);

Output
======
Number of passed arguments: 3