Wednesday, September 9, 2015

example of global scope and php current page using PHP_SELF

<?php
$x = 5;
$y = 7;
function add(){
    global $x, $y; //can't assign any value when declaring global @ same line
    return $x + $y;
}
echo add();

echo '<br>';
echo $_SERVER['PHP_SELF']; //this will return the current page location

No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }