WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP5 and __get and __set
Categories : PHP, PHP Classes Click here to Update Your Picture
Joseph Crawford
Date : Aug 30th 2004
Grade : 3 of 5 (graded 6 times)
Viewed : 19476
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Joseph Crawford
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

_get and _set are new features to php5. when you use $obj->propertyName if the property was not defined in the class like :

<?php
private $propertyName;
?>


then it get's added to the $properties property, which is an array.

so if i do

<?php
$test
->MyProp = "testing";
?>


and there is not a $MyProp; defined in the class then it pushes it to the properties array like so

<?php
array (
'MyProp' => "testing",
);
?>


also when i do :

<?php
echo $test->MyProp;
?>


because there is not a property named MyProp defined it checks the properties array for the value.

these are some nice functions, if you have never read about them this will show you an easy way to keep a site configuration or something else useful :

<?php
class Test {
  var
$properties;
  function
__set($property_name, $val) {
   
$this->properties[$property_name] = $val;
  }
   
  function
__get($property_name) {
    if(isset(
$this->properties[$property_name])) {
      return(
$this->properties[$property_name]);
    } else {
      return(
NULL);
    }
  }
}


Usage Example
<?php
//There's the class now let's see it in use

$t = new Test();
$t->MyProp = "Property1";
echo
$t->MyProp;

/*
when you print_r the object you will see these results

Test Object
(
  [properties] => Array
  (
    [MyProp] => Property1
  )
)
*/
?>

notice how MyProp was turned into an array key Maybe now you can see how usefull these 2 functions really are ;)

Combine this with the code example i did about Singleton Patterns and PHP5 and you have a good start to a nice object design.



A very basic and fast XML parser
Categories : PHP, PHP Classes, XML
Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
POP3 Class
Categories : PHP Classes, PHP, Email
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
MySQL Connection/Query Class
Categories : Databases, MySQL, PHP, PHP Classes
Simple class for accessing databases like MSSql Server, Oracle etc by Raju
Categories : PHP, MS SQL Server, Databases, PHP Classes, Oracle
Render TTF Text to PNG. Text message, font, size, rotation, padding, color, background, and transparency can all be defined via URL.
Categories : PHP, PHP Classes, Graphics
Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers.
Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms
simple shopping cart for php3
Categories : PHP, PHP Classes, Complete Programs, Ecommerce
Class: Info on Users, Servers and the running script
Categories : PHP, Classes and Objects, User Interface, PHP Classes
Ajax PHP Tree (Left and Right) with MySQL
Categories : PHP, Databases, MySQL, AJAX, PHP Classes
YellowPages Content Grabber (PHP5 +)
Categories : PHP, PHP Classes, Regexps, Databases, MySQL
AutoCMS - This class can be used to generate a basic content site.
Categories : PHP, Content Management, PHP Classes
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script