File: IncludingFileStandard.xml

package info (click to toggle)
php-codesniffer 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,092 kB
  • sloc: php: 30,445; xml: 3,768; makefile: 15; pascal: 8; sh: 6
file content (24 lines) | stat: -rw-r--r-- 1,078 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<documentation title="Including Code">
    <standard>
    <![CDATA[
    Anywhere you are unconditionally including a class file, use <em>require_once</em>. Anywhere you are conditionally including a class file (for example, factory methods), use <em>include_once</em>. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with <em>require_once</em> will not be included again by <em>include_once</em>.
    ]]>
    </standard>
    <standard>
    <![CDATA[
    Note that <em>include_once</em> and <em>require_once</em> are statements, not functions. Parentheses should not surround the subject filename.
    ]]>
    </standard>
    <code_comparison>
        <code title="Valid: used as statement">
        <![CDATA[
require_once 'PHP/CodeSniffer.php';
        ]]>
        </code>
        <code title="Invalid: used as function">
        <![CDATA[
require_once<em>(</em>'PHP/CodeSniffer.php'<em>)</em>;
        ]]>
        </code>
    </code_comparison>
</documentation>