[go: up one dir, main page]

0% found this document useful (0 votes)
22 views2 pages

List of Syntax Used in PHP!: Here's A Cheat Sheet To Add To The Collection of PHP Programmers, Happy Coding!

This document provides a cheat sheet of common PHP syntax constructs organized into categories such as blocks, comments, comparisons, constants, functions, and control flow. It lists syntax like curly braces for blocks, slashes for different types of comments, comparison operators like less than, and control flow keywords like if, elseif, else, for, while and switch. The goal is to serve as a quick reference for PHP programmers.

Uploaded by

Laci Kártik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

List of Syntax Used in PHP!: Here's A Cheat Sheet To Add To The Collection of PHP Programmers, Happy Coding!

This document provides a cheat sheet of common PHP syntax constructs organized into categories such as blocks, comments, comparisons, constants, functions, and control flow. It lists syntax like curly braces for blocks, slashes for different types of comments, comparison operators like less than, and control flow keywords like if, elseif, else, for, while and switch. The goal is to serve as a quick reference for PHP programmers.

Uploaded by

Laci Kártik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

List Of Syntax Used In PHP!

Here's a cheat sheet to add to the collection of PHP programmers, happy coding!
Our previous articles with List Of Syntax Used In Python and Mathematica received warm response
from the readers. While some loved and appreciated the articles, quite a few asked for similar list on
PHP. Hence, on popular demand, we bring to you a cheat sheet on syntax used in PHP.
Language Category: Object Oriented, Dynamically typed
Various
block (grouping statements, especially when statements are
{ ... }
not expressions)
breaking lines (useful when end-of-line and/or indentation has
nothing needed
a special meaning)
/* ... */
commenting (non nestable)
#
commenting (until end of line)
//
commenting (until end of line)
< > <= >=
comparison
strcmp
comparison (returns 3 values (i.e. inferior, equal or superior))
/** ... */(1)
documentation comment (non nestable)
Err:510
equality / inequality (shallow)
( ... )
grouping expressions
__LINE__ __FILE__
information about the current line and file
eval
runtime evaluation
case-sensitive: variables
case-insensitive: keywords, functions, tokens (case-sensitivity (keywords, variable identifiers...))
constants...
[_a-zA-Z][_a-zA-Z0-9]*
tokens (variable identifier regexp)
=
variable assignment or declaration (assignment)
Functions
create_function(',','...')
anonymous function
f(a,b,...)
function call
f()
function call (with no parameter)
Return(3)
function return value (breaks the control flow)
Control Flow
continue / break
breaking control flow (continue / break)
Return(3)
breaking control flow (returning a value)
if (c) ...
if_then
if (c): ... endif
if_then
if (c) b1 elseif (c2) b2 else b3
if_then_else
if (c): b1 elseif (c2): b2 else: b3 endif

if_then_else

c ? b1 : b2
for
for ($i = 1; $i <= 10; $i--) ...

if_then_else
loop (for "a la C" (while + initialisation))
loop (for each value in a numeric range, 1 decrement)
loop (for each value in a numeric range, 1 increment (see also
the entries about ranges))
loop (for each value in a numeric range, free increment)
loop (while condition do something)

for ($i = 1; $i <= 10; $i++) ...


for ($i = 1; $i <= 10; $i += 2) ...
while (c) ...
switch (val) {
case v1: ...; break;
case v2: case v3: ...; break;
default: ...;
}

multiple selection (switch)

You might also like