<?php
$txt = 'Hello World!';
class Mensagem
{
public function mostrar1()
{
global $txt;
echo $txt;
}
public function mostrar2()
{
$msg = $GLOBALS['txt'];
echo $msg;
}
}
$msg = new Mensagem();
$msg->mostrar1();
$msg->mostrar2();
PD9waHAKCiR0eHQgPSAnSGVsbG8gV29ybGQhJzsKCmNsYXNzIE1lbnNhZ2VtCnsKCXB1YmxpYyBmdW5jdGlvbiBtb3N0cmFyMSgpCgl7CgkJZ2xvYmFsICR0eHQ7CgkJZWNobyAkdHh0OwoJfQoJCglwdWJsaWMgZnVuY3Rpb24gbW9zdHJhcjIoKQoJewoJCSRtc2cgPSAkR0xPQkFMU1sndHh0J107CgkJZWNobyAkbXNnOwoJfQp9CgokbXNnID0gbmV3IE1lbnNhZ2VtKCk7CiRtc2ctPm1vc3RyYXIxKCk7CiRtc2ctPm1vc3RyYXIyKCk7