Welcome Guest, Not a member yet? Register   Sign In
Which template engine do you use..?
#35

[eluser]DerekF[/eluser]
[quote author="dtrenz" date="1205270137"][quote author="DerekF" date="1205268466"]
Even if short_open_tag isn't deprecated (not only are they disabled by default, but I was pretty sure I read somewhere that there was a chance that PHP 6 was going to remove them altogether), it's generally a bad idea to use them because a) you can't depend on them being activated everywhere (less portability) and b) they are not usable if you use XML files at all. Personally, I find them ugly to use and therefore don't really make the code any cleaner or easier to understand when they're used (just MHO, of course).

[Edit] Sorry, should have clarified: short_open_tag is disabled by default in the "recommended" php.ini file.[/quote]

a) I agree about portability, but if you are coding for a specific server environment that you control (as I do) then it is a non-issue.

b) I'm not familiar with any conflicts with XML unless you are trying to nest PHP in an xml file, which just sounds like trouble. I'm sure there a variety of work-arounds. I've never had problems working with XML with short_open_tag turned on.
[/quote]

I'm not sure what you mean by "nesting PHP in an XML file," but for example, the following code is perfectly valid:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<message>
    &lt;?php foreach ($items as $item) { ?&gt;
        <item>&lt;?php echo $item['title'] ?&gt;</item>
    &lt;?php } ?&gt;
</message>

but is broken if short_open_tag is enabled. (Incidentally, I suppose this is an example of XML embedded in a PHP file.)

Quote:Everyone is entitled to their own opinion, but I think most people would agree on which of these 2 is cleaner:

Code:
<h1>&lt;?=$page_title?&gt;</h1>
&lt;? if ($logged_in) : ?&gt;
<p>Welcome back, &lt;?=$username?&gt;</p>
&lt;? endif; ?&gt;

Code:
<h1>&lt;?php echo $page_title; ?&gt;</h1>
&lt;?php if ($logged_in) : ?&gt;
<p>Welcome back, &lt;?php echo $username; ?&gt;</p>
&lt;?php endif; ?&gt;

How about a third:

Code:
<h1>&lt;?php echo $page_title; ?&gt;</h1>

&lt;?php
if ($logged_in) {
    echo '<p>Welcome back, '. $username .'</p>';
}
?&gt;

or maybe:

Code:
<h1>&lt;?php echo $page_title; ?&gt;</h1>

&lt;?php
if ($logged_in) {
    echo "<p>Welcome back, $username</p>";
}
?&gt;

My point being that what seems obviously clearer to you is not necessarily clearer to everyone else because neither of the code samples you provided suit me. (Again, this is a personal opinion, not trying to ruffle feathers here.)


Messages In This Thread
Which template engine do you use..? - by El Forum - 03-06-2008, 11:56 AM
Which template engine do you use..? - by El Forum - 03-06-2008, 12:32 PM
Which template engine do you use..? - by El Forum - 03-06-2008, 02:49 PM
Which template engine do you use..? - by El Forum - 03-06-2008, 02:54 PM
Which template engine do you use..? - by El Forum - 03-06-2008, 08:41 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 06:32 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 10:08 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 10:15 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 10:27 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 10:58 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 11:18 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 11:24 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 11:28 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 11:38 AM
Which template engine do you use..? - by El Forum - 03-07-2008, 01:41 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 02:24 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 04:00 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 05:58 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 06:47 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 07:47 PM
Which template engine do you use..? - by El Forum - 03-07-2008, 08:54 PM
Which template engine do you use..? - by El Forum - 03-08-2008, 02:02 AM
Which template engine do you use..? - by El Forum - 03-09-2008, 11:14 AM
Which template engine do you use..? - by El Forum - 03-10-2008, 03:12 PM
Which template engine do you use..? - by El Forum - 03-10-2008, 04:56 PM
Which template engine do you use..? - by El Forum - 03-10-2008, 05:09 PM
Which template engine do you use..? - by El Forum - 03-10-2008, 05:18 PM
Which template engine do you use..? - by El Forum - 03-10-2008, 05:54 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 08:15 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 08:48 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 08:49 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 09:20 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 09:47 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 10:15 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 10:37 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 10:43 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 11:54 AM
Which template engine do you use..? - by El Forum - 03-11-2008, 12:13 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 12:20 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 12:23 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 12:28 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 12:55 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 01:07 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 01:41 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 01:48 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 01:48 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 01:48 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 01:59 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 02:00 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 02:07 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 02:08 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 02:12 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 02:16 PM
Which template engine do you use..? - by El Forum - 03-11-2008, 02:20 PM
Which template engine do you use..? - by El Forum - 03-23-2008, 11:38 AM
Which template engine do you use..? - by El Forum - 03-23-2008, 02:41 PM
Which template engine do you use..? - by El Forum - 12-07-2009, 03:57 PM
Which template engine do you use..? - by El Forum - 12-08-2009, 04:50 PM
Which template engine do you use..? - by El Forum - 12-08-2009, 11:32 PM
Which template engine do you use..? - by El Forum - 06-07-2010, 08:03 PM
Which template engine do you use..? - by El Forum - 06-18-2010, 02:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB