Re: php 4.0.2 and args in a function

From: Date: Fri, 01 Sep 2000 19:19:29 +0000
Subject: Re: php 4.0.2 and args in a function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14861@lists.php.net to get a copy of this message
scottrus@ipass.net wrote: > > All - > > I noticed some 'new behavior' with the release of php 4.0.2 and I'm not > sure if it's intended behavior or if it's just my coding style. I had the same "problem". I don't know for sure, but it seems like a new "behaviour" in PHP 4.0.2 that was not present in 4.0.0. And apparently, you and I have the same (or at least similar) coding styles, if that is the case.... > Is there a specific php option I should check for that would generate > these type of warnings? Not sure, but... As it turns out (somehow I didn't know this before today), you can do C++-style default argument values in the function declarations (I believe this is PHP 4.x only). So if I define a function foo ($arg1, $arg2 = "world") { print "$arg1, $arg2\n"; } and call it with foo ("Hello"); I would get Hello, world But if I call it with foo ("Hello", "Dolly"); I would get Hello, Dolly It was much, much easier to add some default argument values to my function declarations than it would have been to add some null-like values to EVERY SINGLE function call that doesn't have enough arguments in my big-huge PHP project. > Thanks for the help. Hope this helps! :o) Stephen. -- Stephen Hui, ARL:UT, Austin, Texas Computer Terms: Programmer - A red-eyed, mumbling mammal capable of conversing with inanimate objects.

« previous php.general (#14861) next »