Code: Select all
$helloworld = "Hello World!";
class Display
{
function HelloWorld()
{
echo $helloworld;
}
}
$display = new Display();
$display->HelloWorld();Ok... Plan B: declare them to be global...
Code: Select all
$helloworld = "Hello World!";
class Display
{
function __construct()
{
global $helloworld;
}
function HelloWorld()
{
echo $helloworld;
}
}
$display = new Display();
$display->HelloWorld();Ok, last attempt. I put the global declaration inside the function:
Code: Select all
$helloworld = "Hello World!";
class Display
{
function HelloWorld()
{
global $helloworld;
echo $helloworld;
}
}
$display = new Display();
$display->HelloWorld();