Глобальні змінні

<?php

$x = 5;

$y = 10;

function myTest() {

    global $x, $y;

    $y = $x + $y;

myTest();  // run function

echo $y; // output the new value for variable $y

?>

<?php

$x = 3;

$y = 2;

function myTest() {

    $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];

myTest();

echo $y; // 5

?>

define("GREETING", "mysite.com");

function myTest() {

    echo GREETING;

}

 

myTest(); // mysite.com