integer, float, boolean, string, array, object, resource, NULL
$variablename =
<value>; //type defined by type of
<value>
$anothervariable =&
$variablename; //Assign by Reference
$arrayname =
array();
$arrayname =
array(<value1> [,
<value2>, ...]);
//Initialized
$arrayname = array(<key>
=> <value> [, <key>
=> <value>, ...]); //Define
Keys
$multiarray = array(<key>
=> array(<value1> [,
<value2>]) [, <key> =>
...]); //Multi-dimensional
array_push(<array>,<value>);
//Push item onto end of
array
array_pop(<array>); //Pop item off end
of
array
[a][r]sort(<array>); //Sort
array, "a" assigns new keys, "r"
reverses
count(<array>[,COUNT_RECURSIVE]);
//Count elements, use COUNT_RECURSIVE for multidimensional array
// Comment text
/* Multi-line comment text */
# Comment text
Arithmetic: + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus)
Relational: == (Equal), === (Equal with type comparison), != (Not equal), <> (Not equal), !== (Not Equal with type comparison), < (Less than), > (Greater than), <= (Less than or equal to), >= (Greater than or equal to), str[case]cmp(<string1>,<string2>); (Binary safe string comparison, insert "case" for case-insensitive)
Logical: ! (logical NOT), && (logical AND), || (logical OR), xor (logical XOR)
Assignment: = (Assign), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), .= (Append), . (Concatenation), %= (Modulus), &= (And), |= (Or), ^= (Exclusive Or), <<= (Left Shift), >>= (Right Shift)
<string> . <string> //Concatenation;
seperate strings with
period)
substr(<string>,
<start>[,
<length>]); // Returns the part of <string>
starting at <start> for <length>
characters.
strlen(<string>); // Return length of
string
str_replace(<search>,<replace>,<string>[,<count>]);
// substitue <count> (default: all) occurances of <search> with
<replace> in
<string>
strpos(<string>,
<search>); //Find <search> in
<string>, return
index.
[l|r]trim(<string>); //
Trim spaces; add "l" to trim only left, "r" to trim only
right.
strto[lower|upper](<string>);
// Convert string to all upper or lower
case
str[case]cmp(<string1>,<string2>);
//Binary safe string comparison, insert "case" for
case-insensitive
explode(<delim>,<string>,[<limit>]);
//Split <string> into array of up to <limit> elements as delimited
by
<delim>
implode(<delim>,<array>);
//Join <array> into string separated by <delim>
if (<condition>) {
<statements>; } elseif
(<condition>) {
<statements>; } else {
<statements>;
}
<condition> ? <truevalue> :
<falsevalue>;
for (<init
stmt>;<condition>;<update
stmt>) {
<statements>;
}
foreach (<array> as
[<value> | <key> =>
<value>]) { <statements>;
[break;] [continue;]
}
while (<condition>) {
<statements>; }
do { <statements>; } while
(<condition>);
switch (<expression>) { case <literal or
type>: <statements>; [break;]
[case...] default: <statements>;
}
function
<function_name>([<parameters>])
{ <statements>;
[return
<value>;]
}
class <class_name> [extends
<base_class>] {
[var [<modifiers>] <class member
variables>;] // Modifiers [public |
private | static] are implemented in
PHP5
function
<class_name>([<constructor_parameters>])
{ <statements>; }
// a class function with a name equal to the class is a constructor
for the class and will be called at the point that a new object is
instantiated.
function
<class_function_name>([<parameters>])
{ <statements>;
}
}
$object = new
class_name([<constructor_parameters>]);
$object->class_function_name([<parameters>]);
class_name::class_function_name([<parameters>]);
//Static
call
$object->class_var //Reference a
variable inside a class object. Note there is no $ in front of class_var.
//In PHP5, private class vars can not be accessed.
try { <statements that may cause error>; } catch (<Exception Class> $exception_name) { <statements to execute when error is caught>; }
setcookie (<cookiename>, [<value>],[<expire_time_in_secs_since_epoch>]);
$_COOKIE['cookiename']; (Returns value of cookie)
session_start(); (Create session)
$_SESSION['key_name'] = value; (Set session variable)
$variablename = $_SESSION['key_name']; (Retrieve value from session variable)
session_destroy(); (Destroy session)
$GLOBALS (Access all global variables in script)
$_SERVER (Access web server variables)
$_GET (Values passed to script through URL)
$_POST (Values passed to script through HTTP Post)
$_COOKIE (Values passed by user cookie)
$_FILES (Values passed by HTTP Post File Uploads)
$_ENV (Values passed to script via the environment)
$_REQUEST (Values passed by URL, HTTP Post, or user Cookies)
$_SESSION (Values passed through user's session)
See also:
file: /Techref/language/php/index.htm, 8KB, , updated: 2013/7/23 09:41, local time: 2024/11/4 00:52,
18.207.160.209:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/techref/language/php/index.htm"> PHP Language</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.