Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17372 > unrolled thread
| Started by | TimW <tim@mysurname.me.uk> |
|---|---|
| First post | 2017-04-25 12:36 +0100 |
| Last post | 2017-04-26 20:21 +0100 |
| Articles | 15 — 7 participants |
Back to article view | Back to comp.lang.php
Is this just a question of personal prefs - echo or not? TimW <tim@mysurname.me.uk> - 2017-04-25 12:36 +0100
Re: Is this just a question of personal prefs - echo or not? Tim Streater <timstreater@greenbee.net> - 2017-04-25 13:10 +0100
Re: Is this just a question of personal prefs - echo or not? "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-04-25 15:00 +0200
Re: Is this just a question of personal prefs - echo or not? Jerry Stuckle <jstucklex@attglobal.net> - 2017-04-25 08:19 -0400
Re: Is this just a question of personal prefs - echo or not? Richard Yates <richard@yatesguitar.com> - 2017-04-25 21:06 -0700
Re: Is this just a question of personal prefs - echo or not? Jerry Stuckle <jstucklex@attglobal.net> - 2017-04-26 07:55 -0400
Re: Is this just a question of personal prefs - echo or not? Richard Yates <richard@yatesguitar.com> - 2017-04-26 09:15 -0700
Re: Is this just a question of personal prefs - echo or not? Jerry Stuckle <jstucklex@attglobal.net> - 2017-04-26 12:48 -0400
Re: Is this just a question of personal prefs - echo or not? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-26 20:40 +0200
Re: Is this just a question of personal prefs - echo or not? "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-04-25 15:03 +0200
Re: Is this just a question of personal prefs - echo or not? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-26 03:14 +0200
Re: Is this just a question of personal prefs - echo or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-25 14:21 +0100
Re: Is this just a question of personal prefs - echo or not? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-26 03:10 +0200
Re: Is this just a question of personal prefs - echo or not? TimW <tim@mysurname.me.uk> - 2017-04-26 19:31 +0100
Re: Is this just a question of personal prefs - echo or not? Tim Streater <timstreater@greenbee.net> - 2017-04-26 20:21 +0100
| From | TimW <tim@mysurname.me.uk> |
|---|---|
| Date | 2017-04-25 12:36 +0100 |
| Subject | Is this just a question of personal prefs - echo or not? |
| Message-ID | <odnc5b$c2c$1@dont-email.me> |
I am teaching myself php very slowly as I go along so bear with me pls.
I am making a theme for the cms I am using. There are two page templates
and I want to be able to style elements differently according to which
template is in use, so hopefully this line is fairly self explanatory:
<body <?php if ($template_file != 'homepage.php')
{ echo "class =\"subpage\"";} ?> >
And it works, fine, but I don't think it would normally be done that
way. Is this better?
<body <?php if ($template_file != 'homepage.php')
{?> class ="subpage" <?php } ?> >
or just different? Is one more acceptable or normal or easier to read?
TW
[toc] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2017-04-25 13:10 +0100 |
| Message-ID | <250420171310321177%timstreater@greenbee.net> |
| In reply to | #17372 |
In article <odnc5b$c2c$1@dont-email.me>, TimW <tim@mysurname.me.uk>
wrote:
>I am teaching myself php very slowly as I go along so bear with me pls.
>
>I am making a theme for the cms I am using. There are two page templates
>and I want to be able to style elements differently according to which
>template is in use, so hopefully this line is fairly self explanatory:
>
><body <?php if ($template_file != 'homepage.php')
> { echo "class =\"subpage\"";} ?> >
Use single quotes for PHP strings *unless* the string needs to contain
the likes of \n. Otherwise PHP has to scan inside the string to look
for them. So:
{ echo 'class="subpage"'; } ?> >
for your second line above.
>And it works, fine, but I don't think it would normally be done that
>way. Is this better?
>
><body <?php if ($template_file != 'homepage.php')
> {?> class ="subpage" <?php } ?> >
>
>or just different? Is one more acceptable or normal or easier to read?
What I don't recall is whether or not going into a PHP section (as when
<?php is encountered) causes significant overhead with PHP having to be
re-initialised each time.
--
There's no obfuscated Perl contest because it's pointless.
- Jeff Polk
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2017-04-25 15:00 +0200 |
| Message-ID | <odnh92$7rs$1@solani.org> |
| In reply to | #17373 |
On 25.04.2017 at 14:10, Tim Streater wrote:
> In article <odnc5b$c2c$1@dont-email.me>, TimW <tim@mysurname.me.uk>
> wrote:
>
>> <body <?php if ($template_file != 'homepage.php')
>> { echo "class =\"subpage\"";} ?> >
>
> Use single quotes for PHP strings *unless* the string needs to contain
> the likes of \n. Otherwise PHP has to scan inside the string to look
> for them. […]
PHP has to recognize escape sequences in single-quoted strings also (\\
and \'), so *this* argument is moot.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2017-04-25 08:19 -0400 |
| Message-ID | <odnen7$kcb$1@jstuckle.eternal-september.org> |
| In reply to | #17372 |
On 4/25/2017 7:36 AM, TimW wrote:
> I am teaching myself php very slowly as I go along so bear with me pls.
>
> I am making a theme for the cms I am using. There are two page templates
> and I want to be able to style elements differently according to which
> template is in use, so hopefully this line is fairly self explanatory:
>
> <body <?php if ($template_file != 'homepage.php')
> { echo "class =\"subpage\"";} ?> >
>
> And it works, fine, but I don't think it would normally be done that
> way. Is this better?
>
> <body <?php if ($template_file != 'homepage.php')
> {?> class ="subpage" <?php } ?> >
>
> or just different? Is one more acceptable or normal or easier to read?
>
> TW
This is really a matter of style. Personally, I prefer the former, but
others may prefer the latter. It's whichever you wish - but whichever
you use, be consistent. It will make reading much easier in the future.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Richard Yates <richard@yatesguitar.com> |
|---|---|
| Date | 2017-04-25 21:06 -0700 |
| Message-ID | <1q60gctt58li1fnd9qbsfl1olvu60q40fl@4ax.com> |
| In reply to | #17375 |
On Tue, 25 Apr 2017 08:19:51 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:
>On 4/25/2017 7:36 AM, TimW wrote:
>> I am teaching myself php very slowly as I go along so bear with me pls.
>>
>> I am making a theme for the cms I am using. There are two page templates
>> and I want to be able to style elements differently according to which
>> template is in use, so hopefully this line is fairly self explanatory:
>>
>> <body <?php if ($template_file != 'homepage.php')
>> { echo "class =\"subpage\"";} ?> >
>>
>> And it works, fine, but I don't think it would normally be done that
>> way. Is this better?
>>
>> <body <?php if ($template_file != 'homepage.php')
>> {?> class ="subpage" <?php } ?> >
>>
>> or just different? Is one more acceptable or normal or easier to read?
>>
>> TW
>
>This is really a matter of style. Personally, I prefer the former, but
>others may prefer the latter. It's whichever you wish - but whichever
>you use, be consistent. It will make reading much easier in the future.
I prefer the latter because the design view of Dreamweaver can see the
"class =..." as html and display it using that class. I guess Design
view doesn't run things through the php engine (although Live view
does).
It also is easier for me to read the color-coding of the code shows
the class spec as html and not as a php string.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2017-04-26 07:55 -0400 |
| Message-ID | <odq1ld$e09$1@jstuckle.eternal-september.org> |
| In reply to | #17381 |
On 4/26/2017 12:06 AM, Richard Yates wrote:
> On Tue, 25 Apr 2017 08:19:51 -0400, Jerry Stuckle
> <jstucklex@attglobal.net> wrote:
>
>> On 4/25/2017 7:36 AM, TimW wrote:
>>> I am teaching myself php very slowly as I go along so bear with me pls.
>>>
>>> I am making a theme for the cms I am using. There are two page templates
>>> and I want to be able to style elements differently according to which
>>> template is in use, so hopefully this line is fairly self explanatory:
>>>
>>> <body <?php if ($template_file != 'homepage.php')
>>> { echo "class =\"subpage\"";} ?> >
>>>
>>> And it works, fine, but I don't think it would normally be done that
>>> way. Is this better?
>>>
>>> <body <?php if ($template_file != 'homepage.php')
>>> {?> class ="subpage" <?php } ?> >
>>>
>>> or just different? Is one more acceptable or normal or easier to read?
>>>
>>> TW
>>
>> This is really a matter of style. Personally, I prefer the former, but
>> others may prefer the latter. It's whichever you wish - but whichever
>> you use, be consistent. It will make reading much easier in the future.
>
> I prefer the latter because the design view of Dreamweaver can see the
> "class =..." as html and display it using that class. I guess Design
> view doesn't run things through the php engine (although Live view
> does).
>
> It also is easier for me to read the color-coding of the code shows
> the class spec as html and not as a php string.
>
I tried Dreamweaver several years ago. The code it generates was crap
then, and hasn't improved since then. Bloated, showing differently on
different browsers...
I can do better and faster by hand. Web pages are not rocket science.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Richard Yates <richard@yatesguitar.com> |
|---|---|
| Date | 2017-04-26 09:15 -0700 |
| Message-ID | <gbh1gc1nf480t720o5pqeeda2o8prlkup9@4ax.com> |
| In reply to | #17382 |
On Wed, 26 Apr 2017 07:55:28 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:
>On 4/26/2017 12:06 AM, Richard Yates wrote:
>> On Tue, 25 Apr 2017 08:19:51 -0400, Jerry Stuckle
>> <jstucklex@attglobal.net> wrote:
>>
>>> On 4/25/2017 7:36 AM, TimW wrote:
>>>> I am teaching myself php very slowly as I go along so bear with me pls.
>>>>
>>>> I am making a theme for the cms I am using. There are two page templates
>>>> and I want to be able to style elements differently according to which
>>>> template is in use, so hopefully this line is fairly self explanatory:
>>>>
>>>> <body <?php if ($template_file != 'homepage.php')
>>>> { echo "class =\"subpage\"";} ?> >
>>>>
>>>> And it works, fine, but I don't think it would normally be done that
>>>> way. Is this better?
>>>>
>>>> <body <?php if ($template_file != 'homepage.php')
>>>> {?> class ="subpage" <?php } ?> >
>>>>
>>>> or just different? Is one more acceptable or normal or easier to read?
>>>>
>>>> TW
>>>
>>> This is really a matter of style. Personally, I prefer the former, but
>>> others may prefer the latter. It's whichever you wish - but whichever
>>> you use, be consistent. It will make reading much easier in the future.
>>
>> I prefer the latter because the design view of Dreamweaver can see the
>> "class =..." as html and display it using that class. I guess Design
>> view doesn't run things through the php engine (although Live view
>> does).
>>
>> It also is easier for me to read the color-coding of the code shows
>> the class spec as html and not as a php string.
>>
>
>I tried Dreamweaver several years ago. The code it generates was crap
>then, and hasn't improved since then. Bloated, showing differently on
>different browsers...
>
>I can do better and faster by hand. Web pages are not rocket science.
It's attempt to dumb down database functions by limiting features and
changing terminology (e.g. "record sets") and putting an interface
between user and code (like WordPress does for html) does certainly
produce some ungainly, even "bloated", results.
But I use it, instead, to directly write and edit code and because I
like its other features, especially search-and-replace,
syntax-checking, and file upload/download/site management.
And, of course, it's what I am used to.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2017-04-26 12:48 -0400 |
| Message-ID | <odqiq1$c60$1@jstuckle.eternal-september.org> |
| In reply to | #17383 |
On 4/26/2017 12:15 PM, Richard Yates wrote:
> On Wed, 26 Apr 2017 07:55:28 -0400, Jerry Stuckle
> <jstucklex@attglobal.net> wrote:
>
>> On 4/26/2017 12:06 AM, Richard Yates wrote:
>>> On Tue, 25 Apr 2017 08:19:51 -0400, Jerry Stuckle
>>> <jstucklex@attglobal.net> wrote:
>>>
>>>> On 4/25/2017 7:36 AM, TimW wrote:
>>>>> I am teaching myself php very slowly as I go along so bear with me pls.
>>>>>
>>>>> I am making a theme for the cms I am using. There are two page templates
>>>>> and I want to be able to style elements differently according to which
>>>>> template is in use, so hopefully this line is fairly self explanatory:
>>>>>
>>>>> <body <?php if ($template_file != 'homepage.php')
>>>>> { echo "class =\"subpage\"";} ?> >
>>>>>
>>>>> And it works, fine, but I don't think it would normally be done that
>>>>> way. Is this better?
>>>>>
>>>>> <body <?php if ($template_file != 'homepage.php')
>>>>> {?> class ="subpage" <?php } ?> >
>>>>>
>>>>> or just different? Is one more acceptable or normal or easier to read?
>>>>>
>>>>> TW
>>>>
>>>> This is really a matter of style. Personally, I prefer the former, but
>>>> others may prefer the latter. It's whichever you wish - but whichever
>>>> you use, be consistent. It will make reading much easier in the future.
>>>
>>> I prefer the latter because the design view of Dreamweaver can see the
>>> "class =..." as html and display it using that class. I guess Design
>>> view doesn't run things through the php engine (although Live view
>>> does).
>>>
>>> It also is easier for me to read the color-coding of the code shows
>>> the class spec as html and not as a php string.
>>>
>>
>> I tried Dreamweaver several years ago. The code it generates was crap
>> then, and hasn't improved since then. Bloated, showing differently on
>> different browsers...
>>
>> I can do better and faster by hand. Web pages are not rocket science.
>
> It's attempt to dumb down database functions by limiting features and
> changing terminology (e.g. "record sets") and putting an interface
> between user and code (like WordPress does for html) does certainly
> produce some ungainly, even "bloated", results.
>
> But I use it, instead, to directly write and edit code and because I
> like its other features, especially search-and-replace,
> syntax-checking, and file upload/download/site management.
>
> And, of course, it's what I am used to.
>
I prefer Eclipse. Great features for HTML, Javascript, PHP - as well as
C, C++ and Java.
And database functions aren't that hard - but probably since I've been
using them for > 30 years, starting with DB2 on mainframes.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-04-26 20:40 +0200 |
| Message-ID | <19157517.epfUpgT3K3@PointedEars.de> |
| In reply to | #17381 |
Richard Yates wrote:
>> [TimW wrote:]
>>> <body <?php if ($template_file != 'homepage.php')
>>> { echo "class =\"subpage\"";} ?> >
>>>
>>> And it works, fine, but I don't think it would normally be done that
>>> way. Is this better?
>>>
>>> <body <?php if ($template_file != 'homepage.php')
>>> {?> class ="subpage" <?php } ?> >
>>>
>>> or just different? Is one more acceptable or normal or easier to read?
>> […]
>
> I prefer the latter because the design view of Dreamweaver can see the
> "class =..." as html […]
> It also is easier for me to read the color-coding of the code shows
> the class spec as html and not as a php string.
This is also true for other source code editors, e.g. Atom (with the
language-php package).
--
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2017-04-25 15:03 +0200 |
| Message-ID | <odnhfk$7rs$2@solani.org> |
| In reply to | #17372 |
On 25.04.2017 at 13:36, TimW wrote:
> I am teaching myself php very slowly as I go along so bear with me pls.
>
> I am making a theme for the cms I am using. There are two page templates
> and I want to be able to style elements differently according to which
> template is in use, so hopefully this line is fairly self explanatory:
>
> <body <?php if ($template_file != 'homepage.php')
> { echo "class =\"subpage\"";} ?> >
>
> And it works, fine, but I don't think it would normally be done that
> way. Is this better?
>
> <body <?php if ($template_file != 'homepage.php')
> {?> class ="subpage" <?php } ?> >
>
> or just different? Is one more acceptable or normal or easier to read?
Guess that's a matter of style. FWIW: I'd prefer something like
<?php
$subpage = ($template_file != 'homepage.php') ? 'subpage' : '';
?>
…
<body class="<?=$subpage?>">
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-04-26 03:14 +0200 |
| Message-ID | <4694299.Dsaprr4szQ@PointedEars.de> |
| In reply to | #17377 |
Christoph M. Becker wrote: > <?php > $subpage = ($template_file != 'homepage.php') ? 'subpage' : ''; > ?> > … > <body class="<?=$subpage?>"> Breaking a fly on the wheel, in this case. DRY. -- PointedEars Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-04-25 14:21 +0100 |
| Message-ID | <8737cwzkpi.fsf@bsb.me.uk> |
| In reply to | #17372 |
TimW <tim@mysurname.me.uk> writes:
> I am teaching myself php very slowly as I go along so bear with me pls.
>
> I am making a theme for the cms I am using. There are two page templates and I want to be able to style elements differently according to which template is in use, so hopefully this line is fairly self explanatory:
>
> <body <?php if ($template_file != 'homepage.php')
> { echo "class =\"subpage\"";} ?> >
>
> And it works, fine, but I don't think it would normally be done that way. Is this better?
>
> <body <?php if ($template_file != 'homepage.php')
> {?> class ="subpage" <?php } ?> >
>
> or just different? Is one more acceptable or normal or easier to read?
I find both rather fussy. Here's yet another way:
<body<?= $template_file != 'homepage.php' ? ' class=subpage' : '' ?>>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-04-26 03:10 +0200 |
| Message-ID | <1532509.nxgZTucpeQ@PointedEars.de> |
| In reply to | #17378 |
Ben Bacarisse wrote:
> TimW <tim@mysurname.me.uk> writes:
>> I am making a theme for the cms I am using. There are two page templates
>> and I want to be able to style elements differently according to which
>> template is in use, so hopefully this line is fairly self explanatory:
>>
>> <body <?php if ($template_file != 'homepage.php')
>> { echo "class =\"subpage\"";} ?> >
>>
>> And it works, fine, but I don't think it would normally be done that way.
>> Is this better?
>>
>> <body <?php if ($template_file != 'homepage.php')
>> {?> class ="subpage" <?php } ?> >
>>
>> or just different? Is one more acceptable or normal or easier to read?
Usually one would use PHP template syntax in templates:
<body
<?php if ($template_file !== 'homepage.php'): ?>
class="subpage"
<?php endif; ?>
>
However, it produces more whitespace. You can work around that:
<body<?php
if ($template_file !== 'homepage.php'):
?> class="subpage"<?php
endif;
?>>
but whether you find that better readable is a matter of preference.
It is also a matter of available syntax highlighting.
You can minify markup output using output buffering and regular expressions,
so that you can write templates easily understandable without output
overhead. A template engine should allow that.
> I find both rather fussy. Here's yet another way:
>
> <body<?= $template_file != 'homepage.php' ? ' class=subpage' : '' ?>>
Do not rely on type conversion:
<body<?= $template_file !== 'homepage.php' ? ' class=subpage' : '' ?>>
But really, if there is only one case where to output something, then a
simple “if” is easier to read.
OTOH, it might be better readable and easier maintainable to make the case
explicit:
<?php if ($template_file === 'homepage.php'): ?>
<body>
<?php else: ?>
<body class="subpage">
<?php endif; ?>
This also indicates that where one has two cases it usually results in more
readable code to use a true-condition instead of a false-condition.
The hardcoded “homepage.php” string does not belong in the template of
course, but a boolean template variable should be queried instead.
--
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | TimW <tim@mysurname.me.uk> |
|---|---|
| Date | 2017-04-26 19:31 +0100 |
| Message-ID | <odqosj$26m$1@dont-email.me> |
| In reply to | #17378 |
On 25/04/17 14:21, Ben Bacarisse wrote:
> TimW <tim@mysurname.me.uk> writes:
>
>> I am teaching myself php very slowly as I go along so bear with me pls.
>>
>> I am making a theme for the cms I am using. There are two page templates and I want to be able to style elements differently according to which template is in use, so hopefully this line is fairly self explanatory:
>>
>> <body <?php if ($template_file != 'homepage.php')
>> { echo "class =\"subpage\"";} ?> >
>>
>> And it works, fine, but I don't think it would normally be done that way. Is this better?
>>
>> <body <?php if ($template_file != 'homepage.php')
>> {?> class ="subpage" <?php } ?> >
>>
>> or just different? Is one more acceptable or normal or easier to read?
>
> I find both rather fussy. Here's yet another way:
>
> <body<?= $template_file != 'homepage.php' ? ' class=subpage' : '' ?>>
>
Hmm. I haven't got to that chapter in the course.
TW
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2017-04-26 20:21 +0100 |
| Message-ID | <260420172021325098%timstreater@greenbee.net> |
| In reply to | #17385 |
In article <odqosj$26m$1@dont-email.me>, TimW <tim@mysurname.me.uk>
wrote:
>On 25/04/17 14:21, Ben Bacarisse wrote:
>> TimW <tim@mysurname.me.uk> writes:
>>
>>> I am teaching myself php very slowly as I go along so bear with me pls.
>>>
>>> I am making a theme for the cms I am using. There are two page templates
>>> and I want to be able to style elements differently according to which
>>> template is in use, so hopefully this line is fairly self explanatory:
>>>
>>> <body <?php if ($template_file != 'homepage.php')
>>> { echo "class =\"subpage\"";} ?> >
>>>
>>> And it works, fine, but I don't think it would normally be done that way.
>>> Is this better?
>>>
>>> <body <?php if ($template_file != 'homepage.php')
>>> {?> class ="subpage" <?php } ?> >
>>>
>>> or just different? Is one more acceptable or normal or easier to read?
>>
>> I find both rather fussy. Here's yet another way:
>>
>> <body<?= $template_file != 'homepage.php' ? ' class=subpage' : '' ?>>
>
>Hmm. I haven't got to that chapter in the course.
You can do things like:
$x = $y==1 ? 8 : 10;
which is rather shorter than:
if ($y==1)
{
$x = 8;
}
else {
$x = 10;
}
--
"The idea that Bill Gates has appeared like a knight in shining armour to
lead all customers out of a mire of technological chaos neatly ignores
the fact that it was he who, by peddling second-rate technology, led them
into it in the first place." - Douglas Adams
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web