Custom Search

News World

Oct 27, 2008

PHP Script : Section 12 : How to create and use function with PHP

Sample 1
function computer ($type = "Lenovo Notebook")
{
return "Make sure that your notebook is $type";
}
echo computer ();
echo "
";
echo computer (" not other then Lenovo");
?>

Result :
Make sure that your notebook is Lenovo Notebook
Make sure that your notebook is not other then Lenovo



Sample 2
function newdate($dt,$mn,$yr){
if(($dt<=31)&&($mn<=12)&strlen($yr)==4){
echo "It is the true date concept
";
echo $dt."-".$mn."-".$yr;
}else{
echo "It is the wrong date concept
";
echo $dt."-".$mn."-".$yr;
}
}
$dt1 = "40";
$mn1 = "11";
$yr1 = "2001";
echo newdate($dt1, $mn1, $yr1)."
";
$dt2 = "22";
$mn2 = "09";
$yr2 = "2003";
echo newdate($dt2, $mn2, $yr2);
?>

Result
It is the wrong date concept
40-11-2001
It is the true date concept
22-09-2003


more : web.solusi@gmail.com

No comments:

IT Conversations

Moneycontrol Latest News

Latest new pages on Computer Hope

Latest from Infoworld

Door Lock

Door Lock Import Top Door Lock from China Contact Quality Manufacturers Now