Re: passing parameters to functions
| From: | O. | Date: | Thu, 20 Jul 2000 20:29:22 +0000 |
| Subject: | Re: passing parameters to functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7472@lists.php.net to get a copy of this message | ||
""T.R. Henigson"" <ted@3bits.com> wrote in message
news:006f01bff26e$bda11c80$02fea8c0@u3...
> I have a function which has four parameters. I can pass variables
> to each of the four parameters by calling the function
>
> Example($parameter1=0,$parameter2=0,$parameter3=0,$parameter4=0);
>
> But if I assign the variable $temp, the concatenated string of
> the four parameters delimited with commas and then call the function
> as follows
>
>
> $temp=$parameter1.",".$parameter2.",".$parameter3.",".$parameter4;
> Example($temp);
>
> It ends up considering $temp as $parameter1 in the function, and then
> using default values for the other three parameters. How do I get the
> comma-delimited string to map to all four parameters?
Can't. Use an array, or use explode inside Example() and pass only one
parameter.
>
> Ted Henigson
>
>
> Bonus question: In quoting strings, if I don't have to do any variable
> interpolation, does it matter whether I use single or double quotes?
I believe (and I could be wrong) that in some languages (C/C++, for example)
'X' encloses a single byte, while "" encloses strings of bytes. In PHP,
there seems to be no difference. IMHO, it's better to standardize on that.
You save little effort by doing ' instead of shift + '.
--
O.