note 98769 added to language.references.pass

From: Date: Tue, 06 Jul 2010 15:05:45 +0000
Subject: note 98769 added to language.references.pass
Groups: php.notes 
Request: Send a blank email to php-notes+get-170737@lists.php.net to get a copy of this message
If you call it without nothing (no variable, no constant) then a new variable is created with null or the default parameter. If a null parameter is passed, then this (null) variable is used, even with a default value specified. A simple example: <?php print '<pre>'; function foo(&$a=5){ $a +=2; print "\nIn foo => $a"; } function bar(&$a){ $a += 2; print "\nIn bar => $a"; } $a; $b; print "Initial:\n"; var_dump($a, $b); foo(); bar(); print "\nAfter void call:\n"; var_dump($a, $b); foo($a); bar($b); print "\nAfter passed:\n"; var_dump($a, $b); print '</pre>'; ?> Output is: "Initial: NULL NULL In foo => 7 In bar => 2 After void call: NULL NULL In foo => 2 In bar => 2 After passed: int(2) int(2)" Note that null is equal to 0 in a mathematical expresion. ---- Server IP: 69.147.83.197 Probable Submitter: 80.33.99.95 ---- Manual Page -- http://www.php.net/manual/en/language.references.pass.php Edit -- https://master.php.net/note/edit/98769 Del: integrated -- https://master.php.net/note/delete/98769/integrated Del: useless -- https://master.php.net/note/delete/98769/useless Del: bad code -- https://master.php.net/note/delete/98769/bad+code Del: spam -- https://master.php.net/note/delete/98769/spam Del: non-english -- https://master.php.net/note/delete/98769/non-english Del: in docs -- https://master.php.net/note/delete/98769/in+docs Del: other reasons-- https://master.php.net/note/delete/98769 Reject -- https://master.php.net/note/reject/98769 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170737) next »