PHP Classes
Icontem

File: example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Benjamin Falk  >  StructObject  >  example.php  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: StructObject
Create objects from list of strict type variables
 

Contents

Class file image Download
<?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!";
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products