php 26 before variable

Solutions on MaxInterview for php 26 before variable by the best coders in the world

showing results for - "php 26 before variable"
Eduardo
29 Jan 2018
1It passes a reference to the variable so when any variable assigned the reference 
2is edited, the original variable is changed. They are really useful when making 
3functions which update an existing variable. Instead of hard coding which variable 
4is updated, you can simply pass a reference to the function instead.
5
6Example
7
8<?php
9    $number = 3;
10    $pointer = &$number;  // Sets $pointer to a reference to $number
11    echo $number."<br/>"; // Outputs  '3' and a line break
12    $pointer = 24;        // Sets $number to 24
13    echo $number;         // Outputs '24'
14?>
15