SlideShare a Scribd company logo
010010100101011010101101001010101001011101011010
Data Types
integer, float, boolean, string, array, object, resource, NULL
Variable Declarations
$variablename = <value>;
$anothervariable =& $variablename; (Assign by Reference)
Declare Array
$arrayname = array();$arrayname = array();
Initialize Array
$arrayname = array(<value1>, <value2>, <value3>);
$arrayname = array(<key> => <value>, <key> => <value>); (Define Keys)
$multiarray = array(<key> => array(<value1>,<value2>)); (Multi-dimensional)
Common Array Functions
sort(<array>); (Sort array assigns new keys)
asort(<array>); (Sort array maintain keys)asort(<array>); (Sort array maintain keys)
rsort(<array>); (Sort array in reverse, new keys)
arsort(<array>); (Sort array in reverse, maintain keys)
count(<array>); (Count elements)
count(<array>,COUNT_RECURSIVE); (Count multidimensional array)
array_push(<array>,<value>); (Push item onto end of array)
array_pop(<array>); (Pop item off end of array)
CommentsComments
// Comment text
/* Multi-line comment text */
# Comment text
Arithmetic Operators
+ (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus)
Relational Operators
== (Equal), === (Equal with type comparison), != (Not equal), <> (Not equal), !== (Not Equal== (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)
Logical Operators
! (logical NOT), && (logical AND), || (logical OR), xor (logical XOR)
Assignment Operators
= (Assign), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), .== (Assign), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), .=
(Concatenation), %= (Modulus), &= (And), |= (Or), ^= (Exclusive Or), <<= (Left Shift), >>=
(Right Shift)
String Concatenation
. (Period)
String Manipulation
substr(<string>,<start>,[<length>]);
strlen(<string>);strlen(<string>);
trim(<string>);
ltrim(<string>); // Trim left
rtrim(<string>); // Trim right
strtolower(<string>);
strtoupper(<string>);
str_replace(<search>,<replace>,<string>,[<count>]);
strpos(<string>, <search>);strpos(<string>, <search>);
strcmp(<string1>,<string2>); (Binary safe string comparison)
strcasecmp(<string1>,<string2>); (Binary safe case-insensitive comparison)
explode(<delim>,<string>,[<limit>]); (Break string into array)
implode(<delim>,<array>); (Join array into string separated by delim)
Cookies
setcookie (<cookiename>, [<value>],[<expire_time_in_secs_since_epoch>]);
$_COOKIE['cookiename']; (Returns value of cookie)$_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)
Error Handling
try {try {
<statements that may cause error>;
}
catch (<Exception Class> $exception_name)
{
<statements to execute when error is caught>;
}
Super 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 ($_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)
If Else
if (<condition 1>)
{ <statement 1>; }
elseif (<condition 2>)elseif (<condition 2>)
{ <statement 2>; }
else
{ <statement 3>; }
Inline If (Ternary)
<condition> ? true : false;
For Loop
for (<initialize>;<condition>;<update>)for (<initialize>;<condition>;<update>)
{
<statements>;
}
For Each Loop
foreach (<array> as [<value> |<key> => <value>])
{
<statements>;<statements>;
[break];
[continue];
}
While Loop
while (<condition>)
{
<statements>;<statements>;
}
Do-While Loop
do
{
<statements>;
} while (<condition>);
SwitchSwitch
switch (<expression>)
{
case <literal or type>:
<statements>;
[break;]
case <literal or type>:
<statements>;<statements>;
[break;]
default:
<statements>;
}
Function Structure
function <function_name>([<parameters>])function <function_name>([<parameters>])
{
<statements>;
[return <value>;]
}
Class Structure
class <class_name> [<extends base_class>]
{{
[var | <modifiers*>] [<class member variables>];
[<modifiers*>] function <function_name>([<parameters>])
{
<statements>;
}
}
* Modifiers <public | pr ivate | static> are implemented in PHP5
Declare and Use Class
$variable = new class_name();
$variable->function_name();
class_name::function_name(); (Static call)
Download More Reference Sheets & Get Programming Help @
http://www.DreamInCode.net
Edited By: hotsnoj, Martyr2
Published: October 18, 2007

More Related Content

What's hot (15)

PDF
JavaOne 2017 | JShell: The Ultimate Missing Tool
Hakan Özler
 
PDF
Separation of concerns - DPC12
Stephan Hochdörfer
 
PDF
The Ring programming language version 1.6 book - Part 46 of 189
Mahmoud Samir Fayed
 
PDF
Coding website
PutuMahendra Wijaya
 
PDF
The Ring programming language version 1.5.4 book - Part 44 of 185
Mahmoud Samir Fayed
 
KEY
Introduction à CoffeeScript pour ParisRB
jhchabran
 
DOC
Implementation Specifications
Unmon Mukherjee
 
PDF
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Suyeol Jeon
 
PDF
The Ring programming language version 1.2 book - Part 32 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 34 of 88
Mahmoud Samir Fayed
 
PDF
veracruz
tutorialsruby
 
PDF
The Ring programming language version 1.6 book - Part 31 of 189
Mahmoud Samir Fayed
 
PDF
Dependency Injection in Laravel
HAO-WEN ZHANG
 
KEY
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 
DOC
Php
Linh Tran
 
JavaOne 2017 | JShell: The Ultimate Missing Tool
Hakan Özler
 
Separation of concerns - DPC12
Stephan Hochdörfer
 
The Ring programming language version 1.6 book - Part 46 of 189
Mahmoud Samir Fayed
 
Coding website
PutuMahendra Wijaya
 
The Ring programming language version 1.5.4 book - Part 44 of 185
Mahmoud Samir Fayed
 
Introduction à CoffeeScript pour ParisRB
jhchabran
 
Implementation Specifications
Unmon Mukherjee
 
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Suyeol Jeon
 
The Ring programming language version 1.2 book - Part 32 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 34 of 88
Mahmoud Samir Fayed
 
veracruz
tutorialsruby
 
The Ring programming language version 1.6 book - Part 31 of 189
Mahmoud Samir Fayed
 
Dependency Injection in Laravel
HAO-WEN ZHANG
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 

Similar to Php reference sheet (20)

PDF
Php tips-and-tricks4128
PrinceGuru MS
 
PDF
PHP tips and tricks
Damien Seguy
 
PPTX
Drupal7 dbtng
Nicolas Leroy
 
PPTX
Array Methods.pptx
stargaming38
 
PPT
Php Chapter 2 3 Training
Chris Chubb
 
PPTX
Array functions for all languages prog.pptx
Asmi309059
 
PPTX
Array functions using php programming language.pptx
NikhilVij6
 
PDF
Php tutorial handout
SBalan Balan
 
DOCX
20220112 sac v1
Sharon Liu
 
PDF
Taking Perl to Eleven with Higher-Order Functions
David Golden
 
PPTX
Php functions
JIGAR MAKHIJA
 
PDF
WordPress 3.1 at DC PHP
andrewnacin
 
PPTX
Php & my sql
Norhisyam Dasuki
 
PDF
Speed Things Up with Transients
Cliff Seal
 
PPT
Arrays in php
Laiby Thomas
 
PPTX
PHP Functions & Arrays
Henry Osborne
 
PDF
DRUPAL 8 STORAGES OVERVIEW
DrupalCamp Kyiv
 
PPT
An Elephant of a Different Colour: Hack
Vic Metcalfe
 
PDF
Php unit the-mostunknownparts
Bastian Feder
 
Php tips-and-tricks4128
PrinceGuru MS
 
PHP tips and tricks
Damien Seguy
 
Drupal7 dbtng
Nicolas Leroy
 
Array Methods.pptx
stargaming38
 
Php Chapter 2 3 Training
Chris Chubb
 
Array functions for all languages prog.pptx
Asmi309059
 
Array functions using php programming language.pptx
NikhilVij6
 
Php tutorial handout
SBalan Balan
 
20220112 sac v1
Sharon Liu
 
Taking Perl to Eleven with Higher-Order Functions
David Golden
 
Php functions
JIGAR MAKHIJA
 
WordPress 3.1 at DC PHP
andrewnacin
 
Php & my sql
Norhisyam Dasuki
 
Speed Things Up with Transients
Cliff Seal
 
Arrays in php
Laiby Thomas
 
PHP Functions & Arrays
Henry Osborne
 
DRUPAL 8 STORAGES OVERVIEW
DrupalCamp Kyiv
 
An Elephant of a Different Colour: Hack
Vic Metcalfe
 
Php unit the-mostunknownparts
Bastian Feder
 
Ad

Recently uploaded (20)

PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Digital Circuits, important subject in CS
contactparinay1
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Ad

Php reference sheet

  • 1. 010010100101011010101101001010101001011101011010 Data Types integer, float, boolean, string, array, object, resource, NULL Variable Declarations $variablename = <value>; $anothervariable =& $variablename; (Assign by Reference) Declare Array $arrayname = array();$arrayname = array(); Initialize Array $arrayname = array(<value1>, <value2>, <value3>); $arrayname = array(<key> => <value>, <key> => <value>); (Define Keys) $multiarray = array(<key> => array(<value1>,<value2>)); (Multi-dimensional) Common Array Functions sort(<array>); (Sort array assigns new keys) asort(<array>); (Sort array maintain keys)asort(<array>); (Sort array maintain keys) rsort(<array>); (Sort array in reverse, new keys) arsort(<array>); (Sort array in reverse, maintain keys) count(<array>); (Count elements) count(<array>,COUNT_RECURSIVE); (Count multidimensional array) array_push(<array>,<value>); (Push item onto end of array) array_pop(<array>); (Pop item off end of array) CommentsComments // Comment text /* Multi-line comment text */ # Comment text Arithmetic Operators + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus) Relational Operators == (Equal), === (Equal with type comparison), != (Not equal), <> (Not equal), !== (Not Equal== (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) Logical Operators ! (logical NOT), && (logical AND), || (logical OR), xor (logical XOR) Assignment Operators = (Assign), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), .== (Assign), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), .= (Concatenation), %= (Modulus), &= (And), |= (Or), ^= (Exclusive Or), <<= (Left Shift), >>= (Right Shift) String Concatenation . (Period) String Manipulation substr(<string>,<start>,[<length>]); strlen(<string>);strlen(<string>); trim(<string>); ltrim(<string>); // Trim left rtrim(<string>); // Trim right strtolower(<string>); strtoupper(<string>); str_replace(<search>,<replace>,<string>,[<count>]); strpos(<string>, <search>);strpos(<string>, <search>); strcmp(<string1>,<string2>); (Binary safe string comparison) strcasecmp(<string1>,<string2>); (Binary safe case-insensitive comparison) explode(<delim>,<string>,[<limit>]); (Break string into array) implode(<delim>,<array>); (Join array into string separated by delim) Cookies setcookie (<cookiename>, [<value>],[<expire_time_in_secs_since_epoch>]); $_COOKIE['cookiename']; (Returns value of cookie)$_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) Error Handling try {try { <statements that may cause error>; } catch (<Exception Class> $exception_name) { <statements to execute when error is caught>; } Super 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 ($_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) If Else if (<condition 1>) { <statement 1>; } elseif (<condition 2>)elseif (<condition 2>) { <statement 2>; } else { <statement 3>; } Inline If (Ternary) <condition> ? true : false; For Loop for (<initialize>;<condition>;<update>)for (<initialize>;<condition>;<update>) { <statements>; } For Each Loop foreach (<array> as [<value> |<key> => <value>]) { <statements>;<statements>; [break]; [continue]; } While Loop while (<condition>) { <statements>;<statements>; } Do-While Loop do { <statements>; } while (<condition>); SwitchSwitch switch (<expression>) { case <literal or type>: <statements>; [break;] case <literal or type>: <statements>;<statements>; [break;] default: <statements>; } Function Structure function <function_name>([<parameters>])function <function_name>([<parameters>]) { <statements>; [return <value>;] } Class Structure class <class_name> [<extends base_class>] {{ [var | <modifiers*>] [<class member variables>]; [<modifiers*>] function <function_name>([<parameters>]) { <statements>; } } * Modifiers <public | pr ivate | static> are implemented in PHP5 Declare and Use Class $variable = new class_name(); $variable->function_name(); class_name::function_name(); (Static call) Download More Reference Sheets & Get Programming Help @ http://www.DreamInCode.net Edited By: hotsnoj, Martyr2 Published: October 18, 2007