You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 349 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Switches

28.4.3. Switches

A switch in PHP allows us to to take certain actions depending on the value of a certain variable, as in the following example, where we check the value of the $pa variable:

switch($pa) {
  case "showpage":
    showpage($pid, $page);
  break;
  case "list_pages_categories":
    list_pages_categories($cid);
  break;
  default:
    list_pages();
  break;
}

In case $pa has the value "showpage", we call the showpage() function, in case it has the value "list_pages_categories", we call the list_pages_categories() function. If $pa does not have any of these two values, or any value at all, we enter the default case and call list_pages(). See also PHP control structures.

Switch statements are often used in module development (especially in the module administration functions, see Section 21.4). So, if you declared in a module admin case file a switch like:

switch($func) {
     case "func-one":
     funct-one();
     break;    
}

you must call it through a link like:

http://www.yoursite.com/modules.php?mop=modload
&name=The_Web_Ring&file=index&func=func-one

If your function needs to have parameters (see Section 28.4.2), your switch will look like:

switch($func) {
    case "func-one":
    funct-one($xid, $xname);
    break;
}

and your link will have to be:

http://www.yoursite.com/modules.php?mop=modload
&name=The_Web_Ring&file=index&func=func-one&xid=$xid&xname=$xname

See also the ADDONS-MODULES file that came with your PHP-Nuke package.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.031 Seconds - 366 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::