php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38247 include('foo') or include 'foo' -> documentation inconsistency
Submitted: 2006-07-28 21:13 UTC Modified: 2006-07-29 19:33 UTC
From: kahennig at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kahennig at gmail dot com
New email:
PHP Version: OS:

 

 [2006-07-28 21:13 UTC] kahennig at gmail dot com
Description:
------------
In the Code Samples found in the documentation, pages for "include", "require", "include_once" and "require_once" these statements are sometimes used with parentheses 

e.g: include_once("a.php");

and sometimes without them 

e.g: require 'prepend.php';

It seems to me that if both are valid, this should be noted in the doc for each of these statements.

Else, if the PEAR Coding Standards are right (see http://pear.php.net/manual/en/standards.including.php) and parentheses should not be used, then it might make sense to fix the examples and add a Note informing of the "correct" way to use these statements. 

I am well aware, that both ways work, but what is the "right" or "prefered" way? Is one deprecated in favor of the other? It might also be a good idea to include the answeres to these questions in the doc.

Also, in the doc these statements are refered to as "include()", "require()", etc. Where they always have the parentheses after them. This seems quite confusing, if they really are not Functions but Statemens (as the Doc. says: "The include() STATEMENT includes and evaluates the specified file." -emphasis mine) It might also be worth eliminating the parentheses in the statement name from the Documentation.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-29 16:17 UTC] sean@php.net
There are lots of language constructs that parse like functions (optionally have parentheses).

include, require, die, echo are all good examples.

There's no necessarily "correct" way to do it, the parser takes care of them and it makes no difference to the end user. PHP's nature is to avoid strictness.

As for your request to note this in the documentation, this is already stated on the include page (to which the require page refers).

S
 [2006-07-29 19:30 UTC] kahennig at gmail dot com
thanks for your answer. That clears it up for me. I have used these statements very often and then ran across the pear recommendation (since I am now trying to follow a coding standard) and that threw me off. I only realized yesterday that you could use these statements without parentheses and that's why I was wondering about what I percieved as an inconsistency... seems like it wasn't one after all.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 02 15:00:03 2025 UTC