[thelist] PHP inside or outside?

Mike Migurski mike-evolt at teczno.com
Sat Apr 24 18:35:33 CDT 2004


> The more times you swap in and out of HTML/PHP, the more work the PHP
> parser has to do - but to be honest I bet the speed difference in this
> regard is absolutely tiny, so it's best to treat this one as a "do
> whatever suits you" situation.

I'd wager the opposite is true, since the parser has to /parse/ PHP, while
it need only echo HTML. Figuring out which is which is a fairly simple
regex job: /<\?(php)?(.*)\?>/, but the actual parsing is much more
complex. Clearly this depends on what the specific code in question is,
though I've read a few statements from developers on the PHP team
indicating that the parser is optimized for dropping into and out of PHP
mode, since this is how the langauge was initially intended to be used.

I was a big fan of printf-style syntax for a while:
	printf('<elemement attribute="%s" />', $value);

But I've recently switched to the syntax style that Tony describes, for
readability and syntax-hilighting reasons, and because it fits comfortably
into a workflow where some files act as templates, and others don't.

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html



More information about the thelist mailing list