Example code of functions in php
<html>
<head>
<title>Functions2</title>
</head>
<body>
<?php
$bar = "outside";
function foo() {
global $bar;
$bar = "inside";
}
foo();
echo $bar . "<br />";
?>
<br />
<?php
// Example using a local variable, arguments and return values
$bar = "outside";
function foo2($var) {
$var = "inside";
return $var;
}
$bar = foo2($bar);
echo $bar . "<br />";
?>
<br />
<?php
function paint($color="red", $room="office") {
echo "The color of the {$room} is {$color}.";
}
paint("blue","bedroom");
?>
</body>
</html>
0 comments:
Post a Comment