|
PHP
An Introduction for Programmers |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
; (except for the last statement)
{ and a }
;
# and the end of the line
is a comment// and the end of the line
is a comment/* and a */
is a comment
long type of the C compiler)double type of the C compiler)
. operator\ is the escape character and can be used to
represent special characters (e.g., \n represents
the newline character) and Unicode characters
(e.g., \u00e9 is é)false, 0, 0.0,
"", an array with 0 elements, and
NULL all evaluate to false
true
$ followed by an identifierNULL
$$
(e.g., $name = "price"; $$name = 5; will
assign the value 5 to the
variable named price)
+)-)*)/)/)%)++) and Decrement (--)-)
>
<
>=
<=
==
===
!=
!==
&&, and
||, or
!
xor
f):
isset(); default values
(i.e., including an assignment) in the formal parameter list;
and/or func_num_args()
and func_get_arg()
global in that function
static modifier in the
initialization
define() function
[] Operator:
count() and sizeof() Functions:
[] operator more than once
To pass a parameter by reference, include an &
before the variable name in the formal parameter list.
To pass a parameter by value, omit the &.
To return by reference, include an & before the
variable name in the formal parameter list and use
the =& operator to assign the result.
To return by value, omit the & and use the =
operator to assign the result.
this:
Membership Operator:
->
public, protected,
or private) and a variable initialization
and method consists of a visibility and
a function declaration
new Operator:
static modifier:: operator and internally using
self and the :: operator
const modifier (not the
define() function):: operator and internally using the
identifier
array)
before the formal parameterNULL)
parent and the :: operatorself and the
:: operator (rather than $this
and the -> operator)
abstract modifier in the declaration
of the class or method
class replaced by interface
implements
class replaced by trait
include and require Statements:
include generates a warning and
require generates a fatal error if the file
is not foundinclude_once and require_once Statements:
namespace statementuse statement
file_exists()
fopen() and fclose()
fread() and fwrite()
fscanf() and fprintf()