13 Local and Global variables in PHP

Program:

<?php

$a = 10;

function display()
{
    global $a;
    echo "Global A= $a <br>";
    $a = 20;
    $b = 30;
    echo "Local B= $b<br>";
}

display();
echo "After change A= $a<br>";
echo "Trying to access Local B = $b"

?>


Output:

Local and Global variables in PHP

Previous
Next Post »