[TYPO3-core] optional array arguments

Dmitry Dulepov dima at spamcop.net
Wed Apr 26 13:52:25 CEST 2006


Hi!

Martin Kutschker wrote:
> Dmitry and I have changed the signature of getURL, so that it takes a
> third argument which is an array and optional.
> I wrote:
> function getURL($url, $includeHeader = 0, $requestHeaders = '')
> Dmitry wrote:
> function getURL($url, $includeHeader = 0, $requestHeaders = false)
> I don't like my version, but IMHO it's the way TYPO3 uses "undefined"
> arrays (there are lots of $arrayVar = '' pseudo-declarations all over
> the place). But I don't like Dmitry's version either.
> 
> Coming from a C background I prefer "$var = NULL;" for such uses.

I do not remember where and how I got a habit to use false as default
value. I think it was inspired by one of PHP code libraries.

For me it is easier to check for false:

	if (false !== $passedParam)

but I kept is_array() in that function too because of our practices. I
used "false" there as default value was because one could think he can
pass headers as "Referer: aaa\r\nUser-agent: bbb" (as string). "false"
at least shows that parameter is not a string.

As to the null, we need to use is_null() function to check it. I also
have C/C++/Java experience in the past, so I used nulls a lot in the
past. But I do like "false" for PHP because it is simpler to check and
makes less round brackets around. Nothing more.

Dmitry.
-- 
"It is our choices, that show what we truly are,
far more than our abilities." (A.P.W.B.D.)



More information about the TYPO3-team-core mailing list