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


Groups > comp.lang.php > #12335

Re: when incuding a page

Message-ID <4742094.G5GMHY2kJp@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-12-20 18:57 +0100
Subject Re: when incuding a page
Newsgroups comp.lang.php
References <1uhcw9wjxnuap$.oya5fj4d12fv.dlg@40tude.net> <m2situui2o.fsf@caradhras.lan> <52adf632$0$6549$9b4e6d93@newsspool4.arcor-online.net>

Show all headers | View raw


Christoph Michael Becker wrote:

> Fyndhorn Elder wrote:
>> richard <noreply@example.com> writes:
>>> <?php inlcude "page.html" ?>
>> […]
>> The correct syntax is include("string") or include('string literal')
> 
> include is not a function, but a statement, so the parentheses are not
> required.

The fascinating thing about “include” is that it works like a function 
although it is a statement.  If the include is successful, it returns 1 by 
default, otherwise FALSE.  And if the include is successful, and the 
included PHP script contains a “return” statement, then the value of the 
“return” statement's parameter (for lack of a better word) is the return 
value of „include“ if execution reaches that statement.

However, in general it is considered good style to omit the parentheses.
It is considered even better style to avoid include* and require* when 
possible, in favor of autoloading.

See also:

<http://php.net/include>
<http://pear.php.net/manual/en/standards.including.php>
<http://pear.php.net/manual/en/pear2cs.rules.php>
<http://php.net/autoload>

Unfortunately, so far the difference between function-like statements and 
functions has never been made clear using different, but consistent code 
style in the PHP manual.


PointedEars
-- 
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

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


Thread

when incuding a page richard <noreply@example.com> - 2013-12-06 12:05 -0500
  Re: when incuding a page "J.O. Aho" <user@example.net> - 2013-12-06 18:16 +0100
    Re: when incuding a page Dennis <nobody@nowhere.invalid> - 2013-12-06 12:29 -0500
  Re: when incuding a page "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2013-12-06 18:09 +0000
  Re: when incuding a page The Natural Philosopher <tnp@invalid.invalid> - 2013-12-06 19:33 +0000
  Re: when incuding a page Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-06 20:44 +0100
  Re: when incuding a page Richard Yates <richard@yatesguitar.com> - 2013-12-06 12:15 -0800
  Re: when incuding a page Scott Johnson <noonehome@chalupasworld.com> - 2013-12-06 13:35 -0800
  Re: when incuding a page Fyndhorn Elder <bubble@caradhras.lan> - 2013-12-15 17:42 +0000
    Re: when incuding a page Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-15 19:34 +0100
      Re: when incuding a page Moon Elf <moonelf@moonelfsystem.net> - 2013-12-15 19:34 +0000
        Re: when incuding a page Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-12-15 21:10 +0000
      Re: when incuding a page Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-20 18:57 +0100

csiph-web