Re: Accessing Class Method

I think you're confusing require_once with require. require_once has
to check if a file has been loaded or not, require does a
straightforward require - hence the speed boost.

About writing straightforward scripts. Using require instead of
require_once will cause php to throw an error the second you try to
redefine a class you already have (which will happen if you require a
file with the same class declaration twice). By all all means, use
require_once, it's a language statement, it's useful when you need to
use it, BUT a thought out OOP should _not_ need the *_once statements.
The flow of an OOP using a robust design paradigm (like MVC for
instance), should allow for full knowledge of which class gets
included where, if not you're looking at a need for a singleton, if
that doesn't help - delegate to the method required.

Like I said, I'm not imposing the sole usage of require over require
once (although I prefer it), I'm also not saying you should rewrite
existing code to gain the 0.xx ms advantage of require_once over

What I _am_ saying is that using plain require over require once has
solid benefits. And heck, if you can whine about his naming
conventions, why can't I about your coding style :)

On Sep 17, 10:36 pm, "Steve" <no....@xxxxxxxxxxx> wrote:
Btw. Try to write an OO application in a manner that would not require
the require_once statement, but rather a plain require. In part,
because it's faster, but mainly because it will force you to write
your applications in a much straightforward manner. Maybe
straightforward isn't the word here, but I'm tired as hell...

if both main_class and html require dal.php and could be used in the same
script, require_once is better and produces less parsing in php...and is
therefore faster than php having to check if it loaded a file already or
not. THAT is straightforward...probably not the word you're looking for.


Relevant Pages

  • Re: query error handling
    ... Doug Miller wrote: ... he is saying "Ah, this feature was introduced in PHP version 5.2". ...
  • Re: Heartbleed bug?
    ... Is simply being linked against the buggy openssl enough to be ... The bug is only exploitable if you run a SSL/TLS server - which is ... possible using PHP. ... but you seem to be saying "No" and then agreeing with me. ...
  • Re: [PHP] Re: Posting Summary for Week Ending 18 January, 2008:
    ... fact that your email address is already plain text on some of the ... The reason the PHP lists require a genuine email ... address for posting is to cut back on spam. ... there should be a clear statement of privacy policy on the PHP ...
  • Re: Open Source Virus
    ... > just saying 'well admins shouldn't be lazy' is a crap attempt at saying ... this has nothing to do with Linux. ... therefore applies equally to PHP running on Windows. ... problem from multiple sources and could obtain fixes from multiple sources. ...
  • Re: bug in is_numeric
    ... When you have run that on an apache PHP installation of the same ... Prints 'okay' ... Saying 'not ok' indicates is_numeric is broken - not that the value is ... incorrect message. ...