binarystorm Posted June 23, 2008 Share Posted June 23, 2008 Im slowing making a simple CMS for my website, called VCMS. It has a core php file called vcmsCORE.php and sensory components can access the CORE which is composed of a bunch of functions. SO basically in the html of a page you just add <? funct_name($var,$var2); ?> and it will spit out a username or whatever. So Im writing a function that accepts a userID (basically the id of the users table in mysql) and the function spits out the correlating information to make a little "profile page." And since a function can only return one variable at a time I was wondering if this idea of mine would work - a function "tree" if you like: function profilePage_MyPersonalProfile($userId,$option) { if($option == 1){ echo"Fred"; } if($option == 2){ echo"[email protected]"; } } Thats it basically. IS that the best way to do it? Or is there a more efficient way. Thanks, Im new at php and just thought this up, hopefully logically. Link to comment https://forums.phpfreaks.com/topic/111422-php-function-tree-idea/ Share on other sites More sharing options...
Stooney Posted June 23, 2008 Share Posted June 23, 2008 And since a function can only return one variable at a time You can return an array. So just pull all of the user data out of the table and put it into a single array and return that. That's the best way to go about it as far as I know. Link to comment https://forums.phpfreaks.com/topic/111422-php-function-tree-idea/#findComment-572011 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.