PHP Classes
Icontem

File: README


  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  >  README  
File: README
Role: Documentation
Content type: text/plain
Description: Tutorial
Class: StructObject
Create objects from list of strict type variables
 

Contents

Class file image Download
=== What is StructObject ===
StructObject is a PHP-Class what behaviors a little
bit like the struct in C/C++.

=== Where does this class come from ===
This class comes from my CMS Ciwii which is not
released yet.

=== How to use StructObject ===
It is simple. You create a new instance of
StructObject and define your properties, like this:

<?php
	require_once "Struct.php";
	$struct		= new StructObject (
		"property1,
		 property2			= with default value,
		 property3			= ' with another default value ',
		 property4A			= Default-Value,
		 property5:integer	= 5"
	);
?>

So, there are many ways to define a property. You
can even define a property with multiple allowed
types:
<?php
	//Code from above
	$struct2	= new StructObject (
		"property:string:integer"
	);
?>

To get its value, you call it like a real property:
<?php
	//Code from above
	echo $struct->property2;
?>

The absolute-variant gets initialized when writing
an upper A to the end of property-name.
Now you can set values to the property. In our example:
<?php
	//Code from above
	$struct->property4		= "Hello world";
?>
If you want to output the content of the property,
you can write the example above. If you only want to
output the content, if it is not default, write an
upper A to the end of its name:
<?php
	/* If value of $struct->propertyA would be Default-Value
	** an empty string would get returned
	*/
	echo $struct->property4A;
?>

Another feature is a strict class-type as property-value.
To define something like that:
<?php
	$struct3	= new StructObject (
		"property:object[MyClass]"
	);
?>
Now the following lines would stop executing the script
with an error-message:
<?php
	//Code from above
	$struct3->property		= 'a string';
?>

 
  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