Login   Register  
PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Benjamin Falk  >  StructObject  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: StructObject
Create objects from list of strict type variables
Author: By
Last change: Added an example for the new feature
Date: 5 years ago
Size: 1,082 bytes


Class file image Download
require_once "Struct.php";
//Defining a class
class anyThing
//Create a new Struct-instance
$struct        = new StructObject (
         property2        = Hello,
         property3        = ' World!',
         property4A        = Default-Value,
         number:integer = 0"
//Output text
$struct->property1        'Robert says: ';
$struct->property2 $struct->property3;
"<br />\n";
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';
$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!";