On 19 Sep 2002 at 16:13, Tom Ray wrote: > I have a question that I have yet to figure out. Let's say I have a PHP > script with multiple fuctions, how do I call on the script to perfom > specific functions through a url? Ex: > http://www.sample.com/script.php?fucntion1
I wouldn't say this is a specific PHP question. True to all web languages I now of, and as many responses :) The quick answer is that most people use a switch statement: $thefunction_call = 'whatever' for instance: switch($thefunction_call) { case "Ask" : $action = 'SeekAnswer'; break; case "SlowSearch" : $action = 'SlowSearch'; break; case "askus" : $action = 'askus'; break; default : $action = 'SeekAnswer'; break; } But there are other ways, too many other ways :), here is one I'm using on a current app: $fid = get_fid($input); $input is the get or post input that I run through a processor (check for stuff I don't like and return new array). The following allows me to use the submit field to call different functions based upon the value of the submit button. function get_fid($input) { $submit2fid = array( 'Mark done'=>'markTaskDone', 'Mark dropped'=>'markTaskDropped', 'Edit'=>'editTask', 'Update All'=>'UpdateAllTasks', ); if(empty($input['fid'])) { if(empty($submit2fid[$input['submit']])) { $fid = 'showAdminPage'; }else{ $fid = $submit2fid[$input['submit']]; } }else{ $fid = $input['fid']; } return $fid; } so now I have a $fid (function id) I actually do something bizarre like this: $app_results = $functions->run($class,$fid); Function has this: return call_user_func(array($this->$class,$fid),$this->global); I'm *trying* to come up with a componentization idea which sounds good but is hard to implement and I've yet to see an implemenation that I like. I run an element of $app_results through it's template $data = $app_results[0]; $status = $app_results[1]; $new_fid = $app_results[2]; // can be empty $body_file = $viewer->Merge($data,$template); $data['content'] = $body_file; $html_file = $viewer->Merge($data,'index.html'); Now I have just one html file which contains the pieces of my app to now be presented to whatever called it (would have different templates and the viewer would manipulate the data depending on the caller). Peter http://www.coremodules.com/ Web Development and Support at Affordable Prices 901-757-8322 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php