> Oh and if one class uses methods in another class .... do I instansiate a
> new object of the other class .... I have seen use of OtherClass::Method
> ....  is this better method of $obj = new OtherClass()  use

The :: is used to access static methods of a class. Static methods can
be used without creating an instance of the class because they dont
use any of the classes member variables.
For example say you have a class with a function for calculating the
area of a rectangle:
class SomeMathFunctions {
    public function calculateRectangle($width, $height) {
        return $width*$height;

To use this function you would need to first create an instance of the
class then call the method using the normal -> :
$funcs = new SomeMathFunctions();
$area = $funcs->calculateRectange(10,15);

But if you create the function as static by using " public static
function calculateRectangle($width, $height) { "
then you can access the method by using just 1 call:
$area = SomeMathFunctions::calculateRectange(10,15);

So for creating utility functions its better to use static methods
since you dont get the overhead of creating a new instance of the

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to