RE: [PHP4BETA] Is this a bug? Default params?
| From: | Samuel Liddicott | Date: | Mon, 09 Aug 1999 17:19:45 +0000 |
| Subject: | RE: [PHP4BETA] Is this a bug? Default params? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3243@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: georgeh@theta.blowtorch.com [mailto:georgeh@theta.blowtorch.com]On
> Behalf Of George Hartz
> Sent: 09 August 1999 05:38 PM
> To: Samuel Liddicott; php4beta@lists.php.net
> Subject: Re: [PHP4BETA] Is this a bug? Default params?
>
> > Function isAdmin($username = "$login[\"username\"]") {
> >
> > Should it have worked in php3 (it did)? Why doesn't it now? Are only
> > constants allowed as default params???
>
> I caught that problem when Beta1 first came out. I was told its a
> non-supported feature, not a bug. (ie, its not going to change.)
>
> It was a real headache for me, I used that functionality literally
> hundreds of times on a dozen sites.
I think it should be a feature, because otherwise we have:
function isAdmin($username) {
if (! isVar($Username)) {
$UserName=$GLOBALS["login"]["username"];
}
everywhere
which is clearly silly, and the kind of thing scripting is meant to help
save the world with.
Even if not implemented as a feature they way the simple version is it is
nice if it was a sort of shorthand for a function pre-amble which would do
the above code the long way round. Does it come down to the fact that its
too hard to parse do you know?
Maybe we could lobby for an eval?
Function isAdmin($username = eval "etc etc") {
Where eval is a special case that is evaled and then could contain the
needed expressions.
Surely it would not be hard for this one function to be supported for
default params? And thus a tiny change is all that is required for code
using this feature.
What say you wise men of Zenda? I know a man Rupert who says it can be
done, and will do it for me if I deliver to him the keys to the castle room
in which resides a certain lady.
etc etc
Sam