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? Quote 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()? Quote 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. Quote 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 } Quote 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/114202-solved-function-questopm/#findComment-587225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.