- 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
Reference
Function arguments can be passed by reference.
/**
* Function arguments, passed by reference
*/
function findAndCount($s, $char, &$j) // Look Here
{
$i = 0;
while($i < strlen($s)) {
if ($s[$i] == $char)
$j++;
$i++;
}
}
findAndCount("abca", "a", $count);
echo $count; // 2
Default values
PHP allows default values, even when parameters are declared as by-reference.
/**
* Default function arguments
*/
function test($x, &$y = null)
{
$y = 100;
}
$x = 1;
$y = 2;
test($x, $y);
echo $y; // 100
Last update: 531 days ago