On Apr 30, 2006, at 10:10 AM, Jochem Maas wrote:

Edward Vermillion wrote:
I'm still trying to get my head around all the OOP stuff and was wondering if there is any basic difference between calling a static function as opposed to creating an object, in situations where both methods will do the same thing for you. Is there any overhead to creating an object from a class that might impact time/memory consumption(efficiency), or does PHP treat these two methods the same? I'm currently working with PHP4 but am also curious as to how it works in PHP5.

creating an object is a lot of overhead,

That's what I was thinking, but wasn't sure. I'm looking for a 'best practice' really, I've just 'discovered' the static keyword in PHP4, and have a very superficial knowledge of it in PHP5.

don't even try to compare objects in php4 and php5 on anything other than
a superficial level - php5 has so much more OO functionality that it's
jsut not funny. :-P
for instance all those '&'s you are using - php5 doesn't
need it (throws E_STRICT errors at you actually if you use them) because
objects are always references (unless you specifically clone them)

I recommend going to php5 if your currently developing new php OO code, this might not be possible due to production env. restriction but it doesn't stop
you installing a copy locally and getting your hands dirty :-)

have fun.

That's what I'm doing now. I've got 5.1.2(?) loaded up on my main dev server and am getting my feet wet with the OOP stuff. The only 'problem' I'm facing at the moment is that a lot of the work I do is for clients on shared hosts, and you know what that means as far as being able to do a total migration to PHP5.

Right now I'm looking at getting the PHP4 code I have into a state that resembles as much as possible what it will look like in PHP5, just to keep the different versions I'm going to end up with as close as possible.

Thanks!
Ed

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

Reply via email to