note 55866 added to functions.arguments

From: Date: Tue, 16 Aug 2005 04:35:37 +0000
Subject: note 55866 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-93706@lists.php.net to get a copy of this message
You can use a function argument as a switch to give you different returns from the same input. function mypagefunction($page, $switch){ switch ($page){ case 'home': $pageinclude = "home.php"; $pagetitle = "This is my home page!"; break; case 'contact': $pageinclude = "contact.php"; $pagetitle = "This is my contact page!"; break; } if ($switch == 1){ return $pageinclude; }else{ return $pagetitle; } } This keeps certain data together in one multi-purpose function. You can modify it for as many uses as needed. example, you could ad keywords for each page, and then call the function for page specific meta-tags. Maybe this will help someone. It works for me! ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55866 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55866&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55866&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55866&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55866&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55866&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55866&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55866&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93706) next »