Function Eight

Before to function eight

Array
(
)

This is inside Function eight()

After function eight

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
)
 

CODE FOLLOWS

<?php

    
include('includes/header1.php');    

    
// code
    
error_reporting(E_ALL);    // set error reporting to all

    
echo('<h1>Function Eight</h1>');

    
//============= functions ===============
    // function eight
    // a function that receives a reference to an array and populates that array.
    // NOTE: the values here are not returned, but rather the values of the referenced 
    // array are changed
    
    
function eight(&$b)
        {
        echo(
"<p>This is inside Function eight() </p>");    
        for(
$i 1$i 10$i++)
            {
            
$b[] = $i;
            }
        
// note there is NO return
        
}


    
$a = array();    // init an array
    
echo("<p>Before to function eight</p>");
    echo(
'<pre>');
    
print_r($a);
    echo(
'</pre>');
        
    
eight($a);        // call to function eight 
    
    
echo("<p>After function eight</p>");
    echo(
'<pre>');
    
print_r($a);
    echo(
'</pre>');

                            
    include(
'includes/footer1.php');    
?>