I have a question when it comes to using classes, constructors and functions
I'm trying to use json_encode and echo the array out. Can anyone point me in the correct direction here? I don't really know what I'm doing wrong, I thought it was correct but I guess not. Any and all help is appreciated. Thanks.
No errors or output.
class information
{
public $motd, $owner, $greeting;
public $array;
function __construct($motd, $owner, $greeting){
$this->motd = $motd;
$this->owner = $owner;
$this->greeting = $greeting;
}
function test(){
$array = array(
'motd' => $motd,
'owner' => $owner,
'greeting' => $greeting
);
$pretty = json_encode($array);
echo $pretty;
}
}
$api = new information('lolol','losslol','lololol');
$api->test;
?>
testmethod.$api->test();