4 ms·
"You have full control on what your php.ini have." If you're writing, for example, an open source application or an application that is hosted by your customer
by wvenable 18y ago
"You have full control on what your php.ini have."
If you're writing, for example, an open source application or an application that is hosted by your customers (I have worked on both) you can't assume you have any control over the php.ini. The recommended php.ini file has short_open_tag disabled and having short_open_tag enabled makes it more difficult to use PHP to template XML files. It's not deprecated yet, but I wouldn't count on it sticking around forever.
All my PHP software works irregardless of the php.ini settings and works across all platforms. If that's not a concern of yours, that's fine. We just have different requirements.
"<?while($r=loop($rs)){?>"
You're making the assumption that my template constructs are just simple 1-to-1 mappings to PHP statements but that's not the case. My {loop} tag gives access the previous entry, whether or not the row is odd or even, whether or not it's the first and last entry, etc. It's a very powerful tag for the kind of common tasks that come up in a web application. But that's just one example, there's also tags for caching template blocks as well as tags for interactive controls. The level of complexity that's hidden behind a few simple tags is enormous -- which is entirely the point. I have lots of code which uses PHP itself for templates so I'm aware of the difference. I didn't start using templates, I started the other way and worked towards using templates because they make the job easier and quicker.
"Here is an idea, better performace is gained by not loading the templating engine at all."
For a compiling template engine, there's the initial cost of compiling the template when it's been changed but then there is very little additional cost. It generates a regular PHP file that's run just any other. Once the app has been running for a few minutes the template engine doesn't need to be loaded at all.
"We can continue discussion without making attacks?"
That wasn't an attack. I was making a point -- the template engine insulates you from all kinds of problems. If you forget to wrap some variable in your h() function, you might never even notice. However you've just opened yourself up to a cross-site scripting attack. And even if you never make mistakes ever, you might not be the only one working on it.