Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17377

Re: Is this just a question of personal prefs - echo or not?

Path csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.php
Subject Re: Is this just a question of personal prefs - echo or not?
Date Tue, 25 Apr 2017 15:03:55 +0200
Organization solani.org
Lines 28
Message-ID <odnhfk$7rs$2@solani.org> (permalink)
References <odnc5b$c2c$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1493125428 8060 eJwFwQEBwCAMAzBLh9Huk7MC9S+BBMHBnYvgguE+qJ1Z0/xQ/fvSe8h2jUJLjHkiJa3b0XouTxIs (25 Apr 2017 13:03:48 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Tue, 25 Apr 2017 13:03:48 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1
Cancel-Lock sha1:BpLmizSlwc6lq8gMkq00DlXD7j8=
Content-Language de-DE
X-NNTP-Posting-Host eJwFwQEBwCAMAzBLDGi3yeG0+JfwBIvBm5vgxsOrSw+5hIH51a5Ia/RSOg57UkdE+6SvQ/4BHmkRow==
In-Reply-To <odnc5b$c2c$1@dont-email.me>
X-User-ID eJwNyMEBwCAIA8CVioEEx6FU9h/B3vMCNLacQY+JqXbCNcq0Xfock/VPNKylZ/kZQ717c04sXA11EIM=
Xref csiph.com comp.lang.php:17377

Show key headers only | View raw


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

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web