| 
	
 | 
 Posted by L. Berger on 05/30/07 17:55 
On May 30, 11:46 pm, "Gregor" <rmba...@comcast.net> wrote: 
> "L. Berger" <straightfwd...@gmail.com> wrote in message 
> 
> news:1180451838.251123.37150@d30g2000prg.googlegroups.com... 
> * * * 
> 
> > 1. Minimize require calls. (And use require instead of include or 
> > include_once or require_once). 
> > 2. Use an accelerator, such as eAccelerator. This compiles your code 
> > and basically boils it down to one include in most cases. 
> 
> * * * 
> 
> Could you explain these for me please, if you have the time? 
> 
> I can understand the obvious reasons to minimize require calls, but why do 
> you prefer, say, "require()" over "require_once()"?  And why not use 
> "include()" for, say, a block of stand-alone text when you would rather see 
> it omitted than have the page not load? 
 
 
Sorry, it was not very clever of me to make a pronouncement without 
explanation. First, let's compare include and require, two 
differences: 
 
1. Include will only include the file when conditionally appropriate, 
require will simply include it. In reality, especially when using an 
accelerator (more about that below), require simply becomes a part of 
your code. This is better than the PHP executable having to do some 
additional processing to figure out whether something was necessary to 
include or not. It's always there. When it is converted to bytecode, 
it's there. 
 
2. Include throws warnings, require throws errors -- which is an 
important consideration for production level code. An application that 
I had worked on (during corporate years) used "includes" of pretty 
important functionality that went into transactions. Because this was 
production server, the "error_reporting" was set to "E_ALL ^ E_NOTICE 
^ E_WARNING". When includes failed, the warnings were not thrown out, 
the transaction went incomplete but done. In cases like these 
"require" is quite important ("includes" with checking for file 
existence would have been much slower). 
 
So yes, it depends on your particular situation and what your 
application does (for small apps either is fine) but require has 
turned out to be more effective for me. 
 
 
 
> I have never heard of an accelerator.  I'm assuming it acts a bit like a css 
> optimizer, perhaps sort of a poor man's framework?  Does eAccelerator ever 
> create bugs, like css optimization programs? 
 
 
Google is your friend :) eAccelerator is the latest version of an 
older caching solution, memturk. It's turned out much better for me 
than APC especially when . Basically, these products compile your PHP 
code into byte code, then store it in memory. As far as I know, 
eAccelerator does not break any functionality and is highly tested by 
the OSS community. There's a good explanation (and some thoroughly 
unscientific testing) at these sites: 
 
http://www.ipersec.com/index.php?q=en/bench_ea_vs_apc   or 
http://www.mysqlperformanceblog.com/2006/08/09/cache-performance-comparison/ 
-- which show that eAccelerator
 
  
Navigation:
[Reply to this message] 
 |