<s>
The	O
syntax	O
and	O
semantics	B-Application
of	O
PHP	B-Application
,	O
a	O
programming	O
language	O
,	O
form	O
a	O
set	O
of	O
rules	O
that	O
define	O
how	O
a	O
PHP	B-Application
program	O
can	O
be	O
written	O
and	O
interpreted	O
.	O
</s>
<s>
Historically	O
,	O
the	O
development	O
of	O
PHP	B-Application
has	O
been	O
somewhat	O
haphazard	O
.	O
</s>
<s>
To	O
counter	O
this	O
,	O
the	O
PHP	B-Application
Framework	O
Interop	O
Group	O
(	O
FIG	O
)	O
has	O
created	O
The	O
PHP	B-Language
Standards	I-Language
Recommendation	I-Language
(	O
PSR	O
)	O
documents	O
that	O
have	O
helped	O
bring	O
more	O
standardization	O
to	O
the	O
language	O
since	O
2009	O
.	O
</s>
<s>
Some	O
keywords	O
represent	O
things	O
that	O
look	O
like	O
functions	O
,	O
some	O
look	O
like	O
constants	O
,	O
but	O
they	O
are	O
actually	O
language	B-Language
constructs	I-Language
.	O
</s>
<s>
PHP	B-Application
generally	O
follows	O
C	B-Language
syntax	O
,	O
with	O
exceptions	O
and	O
enhancements	O
for	O
its	O
main	O
use	O
in	O
web	O
development	O
,	O
which	O
makes	O
heavy	O
use	O
of	O
string	O
manipulation	O
.	O
</s>
<s>
PHP	B-Application
variables	I-Application
must	O
be	O
prefixed	O
by	O
"	O
$	O
"	O
.	O
</s>
<s>
This	O
allows	O
PHP	B-Application
to	O
perform	O
string	O
interpolation	O
in	O
double	O
quoted	O
strings	O
,	O
where	O
backslash	O
is	O
supported	O
as	O
an	O
escape	B-Algorithm
character	I-Algorithm
.	O
</s>
<s>
No	O
escaping	O
or	O
interpolation	O
is	O
done	O
on	O
strings	O
delimited	B-Algorithm
by	O
single	O
quotes	O
.	O
</s>
<s>
PHP	B-Application
also	O
supports	O
a	O
C-like	O
sprintf	O
function	O
.	O
</s>
<s>
PHP	B-Application
supports	O
an	O
optional	O
object	B-Language
oriented	I-Language
coding	O
style	O
,	O
with	O
classes	O
denoted	O
by	O
the	O
class	O
keyword	O
.	O
</s>
<s>
The	O
PHP	B-Application
processor	O
only	O
parses	O
code	O
within	O
its	O
delimiters	B-Algorithm
.	O
</s>
<s>
Anything	O
outside	O
its	O
delimiters	B-Algorithm
is	O
sent	O
directly	O
to	O
the	O
output	O
and	O
not	O
parsed	O
by	O
PHP	B-Application
.	O
</s>
<s>
The	O
only	O
open/close	O
delimiters	B-Algorithm
allowed	O
by	O
PSR-1	O
are	O
""	O
and	O
""	O
or	O
and	O
.	O
</s>
<s>
The	O
purpose	O
of	O
the	O
delimiting	B-Algorithm
tags	O
is	O
to	O
separate	O
PHP	B-Application
code	O
from	O
non-PHP	O
data	O
(	O
mainly	O
HTML	B-Language
)	O
.	O
</s>
<s>
Although	O
rare	O
in	O
practice	O
,	O
PHP	B-Application
will	O
execute	O
code	O
embedded	O
in	O
any	O
file	O
passed	O
to	O
its	O
interpreter	O
,	O
including	O
binary	O
files	O
such	O
as	O
PDF	O
or	O
JPEG	O
files	O
,	O
or	O
in	O
server	O
log	O
files	O
.	O
</s>
<s>
Everything	O
outside	O
the	O
delimiters	B-Algorithm
is	O
ignored	O
by	O
the	O
PHP	B-Application
parser	O
and	O
is	O
passed	O
through	O
as	O
output	O
.	O
</s>
<s>
These	O
recommended	O
delimiters	B-Algorithm
create	O
correctly	O
formed	O
XHTML	B-Language
and	O
other	O
XML	B-Protocol
documents	I-Protocol
.	O
</s>
<s>
If	O
proper	O
XML	B-Protocol
validation	O
is	O
not	O
an	O
issue	O
,	O
and	O
a	O
file	O
contains	O
only	O
PHP	B-Application
code	O
,	O
it	O
is	O
preferable	O
to	O
omit	O
the	O
PHP	B-Application
closing	O
(?>	O
)	O
tag	O
at	O
the	O
end	O
of	O
the	O
file	O
.	O
</s>
<s>
Other	O
delimiters	B-Algorithm
can	O
be	O
used	O
on	O
some	O
servers	O
,	O
though	O
most	O
are	O
no	O
longer	O
supported	O
.	O
</s>
<s>
Prior	O
to	O
PHP	B-Application
5.4.0	O
this	O
was	O
also	O
controlled	O
with	O
short_open_tag	O
,	O
but	O
is	O
always	O
available	O
in	O
later	O
versions	O
.	O
</s>
<s>
As	O
in	O
C	B-Language
,	O
variables	O
may	O
be	O
cast	O
to	O
a	O
specific	O
type	O
by	O
prefixing	O
the	O
type	O
in	O
parentheses	O
.	O
</s>
<s>
PHP	B-Application
treats	O
newlines	O
as	O
whitespace	O
,	O
in	O
the	O
manner	O
of	O
a	O
free-form	B-Language
language	I-Language
.	O
</s>
<s>
Array	O
elements	O
are	O
accessed	O
and	O
set	O
with	O
square	O
brackets	O
in	O
both	O
associative	B-Application
arrays	I-Application
and	O
indexed	O
arrays	O
.	O
</s>
<s>
PHP	B-Application
has	O
three	O
types	O
of	O
comment	O
syntax	O
:	O
/	O
*	O
*	O
/	O
which	O
serves	O
as	O
block	O
comments	O
,	O
and	O
//	O
as	O
well	O
as	O
#	O
which	O
are	O
used	O
for	O
inline	O
comments	O
.	O
</s>
<s>
The	O
usual	O
"	O
Hello	O
World	O
"	O
code	O
example	O
for	O
PHP	B-Application
is	O
:	O
</s>
<s>
The	O
above	O
example	O
also	O
illustrates	O
that	O
text	O
not	O
contained	O
within	O
enclosing	O
PHP	B-Application
tags	O
will	O
be	O
directly	O
output	O
.	O
</s>
<s>
PHP	B-Application
supports	O
:	O
arithmetic	O
operators	O
,	O
assignment	O
operators	O
,	O
bitwise	O
operators	O
,	O
comparison	O
operators	O
,	O
error	O
control	O
operators	O
,	O
execution	O
operators	O
,	O
increment/decrement	O
operators	O
,	O
logical	O
operators	O
,	O
string	O
operators	O
,	O
array	O
operators	O
,	O
conditional	O
assignment	O
operators	O
.	O
</s>
<s>
The	O
syntax	O
of	O
a	O
PHP	B-Application
if	O
...	O
else	O
statement	O
is	O
as	O
follows	O
:	O
</s>
<s>
Since	O
PHP	B-Application
5.3	O
supports	O
Elvis	O
operator	O
(	O
?	O
</s>
<s>
Since	O
version	O
7.0	O
PHP	B-Application
also	O
supports	O
Null	O
coalescing	O
operator	O
(	O
??	O
</s>
<s>
Since	O
version	O
7.4	O
PHP	B-Application
also	O
supports	O
Null	O
coalescing	O
operator	O
with	O
the	O
?	O
</s>
<s>
Since	O
version	O
8.0	O
PHP	B-Application
also	O
supports	O
Safe	O
navigation	O
operator	O
(?->	O
)	O
.	O
</s>
<s>
An	O
example	O
of	O
the	O
syntax	O
of	O
a	O
PHP	B-Application
switch	O
statement	O
is	O
as	O
follows	O
:	O
</s>
<s>
Note	O
that	O
unlike	O
in	O
C	B-Language
,	O
values	O
in	O
case	O
statement	O
can	O
be	O
any	O
type	O
,	O
not	O
just	O
integers	O
.	O
</s>
<s>
PHP	B-Application
8	O
introduces	O
the	O
expression	O
.	O
</s>
<s>
The	O
PHP	B-Language
syntax	I-Language
of	O
a	O
for	B-Language
loop	I-Language
is	O
as	O
follows	O
:	O
</s>
<s>
The	O
syntax	O
for	O
a	O
PHP	B-Application
while	O
loop	O
is	O
as	O
follows	O
:	O
</s>
<s>
The	O
syntax	O
for	O
a	O
PHP	B-Application
do	O
while	O
loop	O
is	O
as	O
follows	O
:	O
</s>
<s>
The	O
syntax	O
for	O
a	O
PHP	B-Application
for	O
each	O
loop	O
is	O
as	O
follows	O
:	O
</s>
<s>
PHP	B-Application
offers	O
an	O
alternative	O
syntax	O
using	O
colons	O
rather	O
than	O
the	O
standard	O
curly-brace	O
syntax	O
(	O
of	O
"{...}"	O
)	O
.	O
</s>
<s>
This	O
style	O
is	O
sometimes	O
called	O
template	O
syntax	O
,	O
as	O
it	O
is	O
often	O
found	O
easier	O
to	O
read	O
when	O
combining	O
PHP	B-Application
and	O
HTML	B-Language
or	O
JavaScript	O
for	O
conditional	O
output	O
:	O
</s>
<s>
Runtime	B-General_Concept
exception	I-General_Concept
handling	O
method	B-Language
in	O
PHP	B-Application
is	O
inherited	O
from	O
C++	B-Language
.	O
</s>
<s>
PHP	B-Application
supports	O
four	O
scalar	O
types	O
:	O
bool	O
,	O
int	O
,	O
float	B-Algorithm
,	O
string	O
.	O
</s>
<s>
PHP	B-Application
has	O
a	O
native	O
Boolean	O
type	O
,	O
named	O
"	O
bool	O
"	O
,	O
similar	O
to	O
the	O
native	O
Boolean	O
types	O
in	O
Java	B-Language
and	O
C++	B-Language
.	O
</s>
<s>
Using	O
the	O
Boolean	O
type	O
conversion	O
rules	O
,	O
non-zero	O
values	O
are	O
interpreted	O
as	O
true	O
and	O
zero	O
as	O
false	O
,	O
as	O
in	O
Perl	B-Language
.	O
</s>
<s>
PHP	B-Application
stores	O
whole	O
numbers	O
in	O
a	O
platform-dependent	O
range	O
.	O
</s>
<s>
They	O
can	O
be	O
specified	O
using	O
floating	B-Algorithm
point	I-Algorithm
notation	O
,	O
or	O
two	O
forms	O
of	O
scientific	O
notation	O
.	O
</s>
<s>
PHP	B-Application
supports	O
strings	O
,	O
which	O
can	O
be	O
used	O
with	O
single	O
quotes	O
,	O
double	O
quotes	O
,	O
nowdoc	O
or	O
heredoc	O
syntax	O
.	O
</s>
<s>
PHP	B-Application
supports	O
two	O
special	O
types	O
:	O
null	O
,	O
resource	O
.	O
</s>
<s>
PHP	B-Application
supports	O
four	O
compound	O
types	O
:	O
array	O
,	O
object	O
,	O
callable	O
,	O
iterable	O
.	O
</s>
<s>
PHP	B-Application
has	O
no	O
true	O
array	O
type	O
.	O
</s>
<s>
PHP	B-Application
arrays	O
are	O
natively	O
sparse	B-Algorithm
and	O
associative	B-Application
.	O
</s>
<s>
Associative	B-Application
array	I-Application
:	O
</s>
<s>
The	O
object	O
data	O
type	O
is	O
a	O
combination	O
of	O
variables	O
,	O
functions	O
and	O
data	O
structures	O
in	O
the	O
object-oriented	B-Language
programming	I-Language
paradigm	O
.	O
</s>
<s>
Since	O
version	O
5.3	O
PHP	B-Application
has	O
first-class	B-Application
functions	I-Application
that	O
can	O
be	O
used	O
e.g.	O
</s>
<s>
It	O
can	O
be	O
any	O
array	O
or	O
generator	O
or	O
object	O
that	O
implementing	O
the	O
special	O
internal	O
Traversable	O
interface	B-Application
.	O
</s>
<s>
PHP	B-Application
has	O
hundreds	O
of	O
base	O
functions	O
and	O
thousands	O
more	O
from	O
extensions	O
.	O
</s>
<s>
Prior	O
to	O
PHP	B-Application
version	O
5.3.0	O
,	O
functions	O
are	O
not	O
first-class	B-Application
functions	I-Application
and	O
can	O
only	O
be	O
referenced	O
by	O
their	O
name	O
,	O
whereas	O
PHP	B-Application
5.3.0	O
introduces	O
closures	O
.	O
</s>
<s>
Function	O
calls	O
must	O
use	O
parentheses	O
with	O
the	O
exception	O
of	O
zero	O
argument	O
class	O
constructor	O
functions	O
called	O
with	O
the	O
PHP	B-Application
new	O
operator	O
,	O
where	O
parentheses	O
are	O
optional	O
.	O
</s>
<s>
A	O
default	O
value	O
for	O
parameters	O
can	O
be	O
assigned	O
in	O
the	O
function	O
definition	O
,	O
but	O
prior	O
to	O
PHP	B-Application
8.0	O
did	O
not	O
support	O
named	O
parameters	O
or	O
parameter	O
skipping	O
.	O
</s>
<s>
Some	O
core	O
PHP	B-Application
developers	O
have	O
publicly	O
expressed	O
disappointment	O
with	O
this	O
decision	O
.	O
</s>
<s>
Specifying	O
the	O
types	O
of	O
function	O
parameters	O
and	O
function	O
return	O
values	O
has	O
been	O
supported	O
since	O
PHP	B-Application
7.0	O
.	O
</s>
<s>
PHP	B-Application
supports	O
true	O
anonymous	B-General_Concept
functions	I-General_Concept
as	O
of	O
version	O
5.3	O
.	O
</s>
<s>
In	O
previous	O
versions	O
,	O
PHP	B-Application
only	O
supported	O
quasi-anonymous	O
functions	O
through	O
the	O
create_function( )	O
function	O
.	O
</s>
<s>
Since	O
version	O
7.4	O
PHP	B-Application
also	O
supports	O
arrow	B-General_Concept
functions	I-General_Concept
syntax	O
(=	O
>	O
)	O
.	O
</s>
<s>
Basic	O
object-oriented	B-Language
programming	I-Language
functionality	O
was	O
added	O
in	O
PHP	B-Application
3	O
.	O
</s>
<s>
Object	O
handling	O
was	O
completely	O
rewritten	O
for	O
PHP	B-Application
5	O
,	O
expanding	O
the	O
feature	O
set	O
and	O
enhancing	O
performance	O
.	O
</s>
<s>
In	O
previous	O
versions	O
of	O
PHP	B-Application
,	O
objects	O
were	O
handled	O
like	O
primitive	O
types	O
.	O
</s>
<s>
The	O
drawback	O
of	O
this	O
method	B-Language
was	O
that	O
the	O
whole	O
object	O
was	O
copied	O
when	O
a	O
variable	O
was	O
assigned	O
or	O
passed	O
as	O
a	O
parameter	O
to	O
a	O
method	B-Language
.	O
</s>
<s>
PHP	B-Application
5	O
introduced	O
private	O
and	O
protected	O
member	B-Application
variables	I-Application
and	O
methods	O
,	O
along	O
with	O
abstract	O
classes	O
and	O
final	O
classes	O
as	O
well	O
as	O
abstract	O
methods	O
and	O
final	B-Language
methods	I-Language
.	O
</s>
<s>
It	O
also	O
introduced	O
a	O
standard	O
way	O
of	O
declaring	O
constructors	O
and	O
destructors	B-Language
,	O
similar	O
to	O
that	O
of	O
other	O
object-oriented	B-Language
languages	I-Language
such	O
as	O
C++	B-Language
,	O
and	O
a	O
standard	O
exception	B-General_Concept
handling	I-General_Concept
model	O
.	O
</s>
<s>
Furthermore	O
PHP	B-Application
5	O
added	O
Interfaces	O
and	O
allows	O
for	O
multiple	O
Interfaces	O
to	O
be	O
implemented	O
.	O
</s>
<s>
Objects	O
implementing	O
ArrayAccess	O
can	O
be	O
used	O
with	O
array	O
syntax	O
and	O
objects	O
implementing	O
Iterator	O
or	O
IteratorAggregate	O
can	O
be	O
used	O
with	O
the	O
foreach	O
language	B-Language
construct	I-Language
.	O
</s>
<s>
The	O
static	O
method	B-Language
and	O
class	B-Application
variable	I-Application
features	O
in	O
Zend	O
Engine	O
2	O
do	O
not	O
work	O
the	O
way	O
some	O
would	O
expect	O
.	O
</s>
<s>
There	O
is	O
no	O
virtual	B-Language
table	I-Language
feature	O
in	O
the	O
engine	O
,	O
so	O
static	B-General_Concept
variables	I-General_Concept
are	O
bound	O
with	O
a	O
name	O
instead	O
of	O
a	O
reference	O
at	O
compile	O
time	O
.	O
</s>
<s>
The	O
method	B-Language
myStaticMethod	O
is	O
a	O
public	O
static	O
method	B-Language
that	O
can	O
be	O
called	O
with	O
Foo::myStaticMethod( )	O
;	O
.	O
</s>
<s>
If	O
the	O
developer	O
creates	O
a	O
copy	O
of	O
an	O
object	O
using	O
the	O
reserved	O
word	O
clone	O
,	O
the	O
Zend	O
engine	O
will	O
check	O
if	O
a	O
__clone( )	O
method	B-Language
has	O
been	O
defined	O
or	O
not	O
.	O
</s>
<s>
If	O
a	O
__clone( )	O
method	B-Language
is	O
defined	O
,	O
then	O
it	O
will	O
be	O
responsible	O
for	O
setting	O
the	O
necessary	O
properties	O
in	O
the	O
created	O
object	O
.	O
</s>
