Posted on August 7, 2013
<?php
// initiate a global variable
global $bundle_of_functionality;
/**
* A PHP Class that does things
*/
class Class_That_Does_Stuff {
/**
* A public class property
*
* (variables that float out here are called
* properties & are accessible everywhere
* inside the class)
*/
public $words_to_say = 'do stuff';
/**
* A public method
*
* (functions in classes are called methods..
* how pretentious)
*/
public function do_stuff() {
// '$this' is a magical keyword to
// reference our class object
echo $this->words_to_say;
// later we'll put $this into $bundle_of_functionality
}
}
// throw the class into our global variable..
// we now have an "object" stashed in a variable.
$bundle_of_functionality = new Class_That_Does_Stuff();
Recent Comments