Re: passing parameters to functions

From: Date: Thu, 20 Jul 2000 18:35:56 +0000
Subject: Re: passing parameters to functions
Groups: php.general 
Request: Send a blank email to php-general+get-7459@lists.php.net to get a copy of this message
Ted, >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? > >Ted Henigson > I don't believe you can. Options that come to mind: 1) pass the string and explode() it to an array inside the function 2) explode() the string to an array and pass the array 3) bite the bullet and pass all 4 parameters separately I am sure there are many more ways to do this. > >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? > It shouldn't. (How many bonus points?) Regards, Carroll Barrett

« previous php.general (#7459) next »