On Mon, 9 Aug 2004 15:14:57 -0400, John W. Holmes
<[EMAIL PROTECTED]> wrote:
> From: "Justin Patrin" <[EMAIL PROTECTED]>
> > > eval($script);
> > > use_cached_code();
> >
> > Ick! eval() is evil!
> 
> You have benchmarks to back that up or experience?
> 

Well, I didn't mean speed-wise necessarily, although it means more
parsing. Much better to use a *function* which is parsed once than
include()ing or eval()ing the same code over and over to (possibly) be
re-parsed. It just makes more sense code structure-wise as well.

> I did a benchmark between using include(), eval(), smarty, pattemplate, and
> a few others and include() and eval() are always the fastest.
> 
> Really depends upon what kind of features you need and what you consider
> "evil". ;)

By evil I mean that it's used for the wrong purposes much of the time.
People aren't aware of the capabilities of the language or are simply
ignorant of good coding style and use eval because it's easy. Heck, I
used eval before I knew how to use $$ and arrays effectively. Here's a
quote that really says it well:

If eval() is the answer, you're almost certainly asking the wrong question.
-- Rasmus Lerdorf, BDFL of PHP

> 
> ---John Holmes...
> 

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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

Reply via email to