<?php
/*
** Let's use StructObject directly in a new object
*/
//Load the struct-file
require_once 'Struct.php';
//Create your own class and extend it with StructObject
class MyClass extends StructObject
{
/*
** properties:
** title:string
** content:string
** count:integer
*/
/*
** The output of the properties
*/
public function output()
{
echo "<h1>".htmlentities($this->title)."</h1>";
echo "<p>".htmlentities($this->content)."</p>";
}
//And the rest your code
/*
** @magic This function gets called on creating an instance
*/
function __construct()
{
parent::__construct(
"title:string,
content:string,
count:integer"
);
}
}
//Now we can create a new instance from our class
$my = new MyClass;
$my->title = "This is the second example";
$my->content = "Just a little example";
$my->count = 10;
$my->output();
?>
|