please dont rip this site

PHP Language

Data Types

integer, float, boolean, string, array, object, resource, NULL

Variable Declarations

$variablename = <value>; //type defined by type of <value>
$anothervariable =& $variablename; //Assign by Reference

Array

$arrayname = array();
$arrayname = array(<value1> [, <value2>, ...]); //Initialized
$arrayname = array(<key> => <value> [, <key> => <value>, ...]); //Define Keys
$multiarray = array(<key> => array(<value1> [, <value2>]) [, <key> => ...]); //Multi-dimensional

Common Array Functions

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

Comments

// Comment text
/* Multi-line comment text */
# Comment text

Operators

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> . <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>

Statements

Flow

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>;] }

Classes

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.

Error Handling

try {
	<statements that may cause error>;
	}
catch (<Exception Class> $exception_name) {
	<statements to execute when error is caught>;
	}

Input / Output

Cookies

setcookie (<cookiename>, [<value>],[<expire_time_in_secs_since_epoch>]);

$_COOKIE['cookiename']; (Returns value of cookie)

Sessions

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

$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/22 13:35,
TOP NEW HELP FIND: 
18.119.125.240:LOG IN

 ©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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/Techref/language/php/index.htm"> PHP Language</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .