- BASICS
- Quotes
- Constants
- Control Structures
-
Reference
- Number Systems
- VARIABLES
- Definition
- Variable Variable
- Exists
- Type Casting
- OPERATORS
- Aritmetic
- Bitwise
- String
- Comparison
- Logical
- FUNCTION
- Definition
- Anonymous
- Reference
- Variable Arguments
- ARRAY
- Basics
- Operations
- Create
- Search
- Modify
- Sort
- Storage
- STRING
- String Basics
- String Compare
- String Search
- String Replace
- String Format
- String Regexp
- String Parse
- Formating
- Json
- STREAMS
- File Open
- Read File
- Read Csv
- File Contents
- Context
- Ob_start
- OOP
- Object Instantiation
- Class Constructor
- Interfaces, Abstract
- Resource Visibility
- Class Constants
- Namespaces
- HTTP
- Headers
- File Uploads
- Cookies
- Sessions
Rererence
In PHP variables are NOT passed by reference (& needed)
/**
* Variable are passed by value (not by reference)
*/
$a = 1;
$x = $a;
$y =& $a; // Look Here
$a = 2;
var_dump($x == 1); // true
var_dump($x != 2); // true
var_dump($y == 2); // true
Array
Reference with foreach changes the array.
/**
* Reference with foreach changes the array
* Use it with care
*/
$A = [1, 2, 3, 4];
foreach ($A as &$val) { // Look Here
$val *= 2;
}
var_dump($A == [2, 4, 6, 8]); // true
var_dump($A != [1, 2, 3, 4]); // true
Last update: 531 days ago