Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

PHP code must always being with the long form opening tag. If a file contains only PHP code, the end tag may optionally be omitted from the end of a the file.

Code Block
languagephp
titleTag Usage
<?php

?>

...

Programming Styles

Strings

Literals

Strings consisting of more than one character should be surrounded with double-quotes ("). Strings consisting of only a single character may be surrounded with single-quotes (').

Code Block
languagephp
$str = "This is a long string";
$chr = 'a';

Concatenation

Run-on Strings

A string whose length requires it to wrap multiple lines should be concatenated with the concatenation character (.) appended at the end of the line, with the carry-over line indented below it.

Code Block
languagephp
$str = "This is a string that needs to " .
 "wrap onto another line.";
Variable Substitution

When a variable needs to be added to a string the string should be broken open and concatenated together to improve readability.

Code Block
languagephp
$name = "Hefo Quient Esbit";
$str = "Hello " . $name . "! How are you?"

Arrays

Numerically Index Arrays

...