MemoryRefresh!

Reference



Questions Answers 0%

Pages   0 from 51
Questions   0 from 84

Reset



Function arguments can also be passed by reference, as opposed to the traditional by-value method, by prefixing them with the by-reference operator &
<?php function myFind($str, $char, &$count) { // -- Look Here -- // for($i=0; $i<strlen($str); $i++) if ($str[$i] == $char) $count++; } myFind("abca", "a", $count); echo $count; // output 2 Unlike PHP 4, PHP 5 allows default values to be specified for parameters even when they are declared as by-reference:
<?php function test($var1, &$var2 = null) { $var2 = "c"; } $var1 = 'a'; $var2 = 'b'; test($var1, $var2); echo $var2; // Output: c
Questions

Related pages

Definition !
Variables !
Anonymous !
Reference !


0% 100%
 
 
0 pages 51 pages
1) Is this code valid? <?php function ($var1, &$var2 = null) {}





2) Which is the correct? <?php function _____ {} test($a, $count); echo $count; // Output: c




Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


Function arguments can also be passed by reference, as opposed to the traditional by-value method, by prefixing them with the by-reference operator &
<?php function myFind($str, $char, &$count) { // -- Look Here -- // for($i=0; $i<strlen($str); $i++) if ($str[$i] == $char) $count++; } myFind("abca", "a", $count); echo $count; // output 2 Unlike PHP 4, PHP 5 allows default values to be specified for parameters even when they are declared as by-reference:
<?php function test($var1, &$var2 = null) { $var2 = "c"; } $var1 = 'a'; $var2 = 'b'; test($var1, $var2); echo $var2; // Output: c



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com