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


Groups > comp.lang.php > #14559

Re: Do you use extra parenthesis for include/require/echo?

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.php
Subject Re: Do you use extra parenthesis for include/require/echo?
Date 2014-11-13 11:48 +0000
Organization A noiseless patient Spider
Message-ID <87ppcruxqz.fsf@bsb.me.uk> (permalink)
References <87bnocvs5m.fsf@ahungry.com>

Show all headers | View raw


Matthew Carter <m@ahungry.com> writes:

> Just a syntactic question - which combination of the above does everyone
> use (or some blend of the two)?
>
> <?php
>
> require_once '/some/file.php';
> echo 'Loaded';
>
> ?>
>
> Or:
>
> <?php
>
> require_once('/some/file.php');
> echo('Loaded');
>
> ?>

I don't use the parentheses.  There are some traps to using them that
are harder to fall into if you never do.  For example, the expression

  include("x.php") ? "all good" : "failed to include file"

does not parse as if include is a function.  If you leave out the ()s
the real parse becomes a much more obvious possibility:

  include "x.php" ? "all good" : "failed to include file"

-- 
Ben.

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


Thread

Do you use extra parenthesis for include/require/echo? Matthew Carter <m@ahungry.com> - 2014-11-12 01:39 -0500
  Re: Do you use extra parenthesis for include/require/echo? "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-13 00:33 +0100
  Re: Do you use extra parenthesis for include/require/echo? Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-12 22:32 -0500
  Re: Do you use extra parenthesis for include/require/echo? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-13 11:48 +0000
    Re: Do you use extra parenthesis for include/require/echo? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-13 22:03 +0100
      Re: Do you use extra parenthesis for include/require/echo? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-13 23:18 +0000
        Re: Do you use extra parenthesis for include/require/echo? Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-13 21:08 -0500
  Re: Do you use extra parenthesis for include/require/echo? crankypuss <crankypuss@nomail.invalid> - 2014-11-14 02:15 -0700

csiph-web