whiteboikyle Posted July 11, 2008 Share Posted July 11, 2008 kk just a quick question.. if you had a function like so function name($name, $name1, $name2){ } Can you just do name($name) or name($name, $name1) or d you have to put all the inputs? Link to comment https://forums.phpfreaks.com/topic/114202-solved-function-questopm/ Share on other sites More sharing options...
DarkWater Posted July 11, 2008 Share Posted July 11, 2008 You have to put in all the inputs unless you set default values? Why? Are you trying to make a function that can take an unlimited number of parameters, like sprintf()? Link to comment https://forums.phpfreaks.com/topic/114202-solved-function-questopm/#findComment-587182 Share on other sites More sharing options...
Andy-H Posted July 11, 2008 Share Posted July 11, 2008 You have to give input for each function variable. Link to comment https://forums.phpfreaks.com/topic/114202-solved-function-questopm/#findComment-587183 Share on other sites More sharing options...
Stephen Posted July 11, 2008 Share Posted July 11, 2008 As DarkWater said, you need default values if you don't want to give an input for whatever reason. For default values you do like: function name($name="",$name1="",$name2=""){ //code } Link to comment https://forums.phpfreaks.com/topic/114202-solved-function-questopm/#findComment-587212 Share on other sites More sharing options...
sasa Posted July 11, 2008 Share Posted July 11, 2008 try <?php function xxx(){ $args = func_get_args(); foreach ($args as $a){ echo $a, "<br />\n"; } } xxx('sasa','aaa','bbb',5); ?> Link to comment https://forums.phpfreaks.com/topic/114202-solved-function-questopm/#findComment-587225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.