I'm trying to get message passing between objects down in my cranium.
I have two classes I want to talk to each other:
1. user class = registers a user
2. validation class = verify data
for example lets say I'm doing a sign up form, user enters in a username and I want to check that user name and if its good - let them register
in the user class I want to set the username from the form and verify its in the right format using the validator class.
Here comes my question....
When using methods of other objects do I need to do a $object = NEW class ? or can I just include that class file and call its methods?
Actually I wanna know what the best way is (most proper for OO)
Right now if I have a class that uses another class I do a NEW in the constructor
Any thoughts? thanks.. I hope that was semi clear. lol
Code: Select all
<?php
class user{
function user()
{
// SET ERROR CLASS
$error = new validation_class();
}
function register()
{
// call to validation class
$error->is_numeric($string);
}
} // end class
?>