Haifa linux club:PHP lecture
Prev Next


functions


<?
function la(){ 
    return 
"lalala\n<br>";


echo 
la();
// will output lalala
?>
Variable scope:
<?

$x 
"XXX";

function 
put_in_x($myparam){ 
    
$x $myparam;


put_in_x("YYY");
echo 
$x;
// will output XXX
?>
using global variables in a function.
<?

$x 
"XXX";

function 
put_in_x($myparam){ 
    global 
$x;
    
$x $myparam;


put_in_x("YYY");
echo 
$x;
// will output YYY
?>





HOME