<?php
require_once "Struct.php";
//Defining a class
class anyThing
{
public $var='Class';
}
//Create a new Struct-instance
$struct = new StructObject (
"property1:string,
property2 = Hello,
property3 = ' World!',
property4A = Default-Value,
anything:object[anyThing],
number:integer = 0"
);
//Output text
$struct->property1 = 'Robert says: ';
echo $struct->property1;
echo $struct->property2 . $struct->property3;
echo "<br />\n";
//Absolute-Variant:
echo $struct->property4."<br />\n"; //Default-Value is the output
echo $struct->property4A."<br />\n"; //Absolute-Variant output: nothing, because property has default-value
$struct->property4 = 'No-Default-Value';
echo $struct->property4A."<br />\n"; //Property has a no-default value, so it gets output
$struct->anything = new anyThing; //Property anything has to get instances from anyThing
echo $struct->anything->var."<br />";
//What happens if we give the property number a string-value
$struct->number = "Hello world!";
?>
|