Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Quote:
|
Assuming the class name is object_one you can call it by object_one::function_one()
|
But only if the method is declared as static (I believe).
A static method being a method that is shared by every instance of a given class.
The second way is "proper" in my opinion, at one exception.
Be aware that PHP does a copy of $object_one when you pass it as a parameter to $object_two.
This means, that if you change somethinf from the inside of $object_two to the $object_one object that is encapsulated in it, it will not reflect on the real $object_one!
To avoid this, you have to use what is called a "passage by reference" of the object $object_one:
PHP Code:
//Object Two
class object_two { var object_one;
function object_two(object_one) { $this->object_one = $object_one; }
//Calling Functions function something_cool() { //Call $this->object_one->another_function(); } }
$object_one = new object_one; $object_two = new object_two(&$object_one);
Notice the "&" before $object_one, this is what tells the PHP engine not to copy the object, but to share the same reference to the place where the object is stored in memory.Here is the PHP.net doc page relative to this:
http://us3.php.net/manual/en/languag...ences.pass.php
__________________
Only a biker knows why a dog sticks his head out the window.
|