voidstate Posted November 29, 2007 Share Posted November 29, 2007 Is it possible to have a variable number of parameters passed to a method? function myMethod( $a, $b ) { // i want to check for $c, $d, $e, etc... here } Cheers voidstate Link to comment https://forums.phpfreaks.com/topic/79392-solved-variable-number-of-parameters-passed-to-a-method/ Share on other sites More sharing options...
adam291086 Posted November 29, 2007 Share Posted November 29, 2007 i dont think so, you set the function up to do the checking. Then you call on the function to check the variables later on. I think i am right but not 100% sure Link to comment https://forums.phpfreaks.com/topic/79392-solved-variable-number-of-parameters-passed-to-a-method/#findComment-401904 Share on other sites More sharing options...
Orio Posted November 29, 2007 Share Posted November 29, 2007 You can have functions that deal with different amount of variables, it's not too hard to do that either. Check the "Variable-length argument lists" section in here, it will tell you what functions you need to use: http://www.php.net/manual/en/functions.arguments.php But I think it's easier to store all of the data in an array and pass that array. You can do much more when it's in an array. Orio. Link to comment https://forums.phpfreaks.com/topic/79392-solved-variable-number-of-parameters-passed-to-a-method/#findComment-401906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.