Jump to content

case and break


irkevin

Recommended Posts

A switch is a way to handle/execute code based on certain conditions. Example...

 

 

<?php

  $content = $_GET['content'];

  switch ($content) {

    case 'members':
      //Load members only area. 
    break;

    case 'login':
      //Load login area. 
    break;

    default:
       // Load main area.
    break;

  }

?>

 

In the above example the switch checks the $content variable and depending on what it's value is, will load the appropriate content.

 

There are tons of example online on using classes in PHP. I definitely recommend looking into it and taking an OOP approach to writing code (Object Oriented Programming).

Link to comment
Share on other sites

Oh thanks for the quick response. . and what about global function.. I think it's something like that

 

function whatever(){

global $first;

echo $first;

}

 

what does the global means there?

 

P.S: sorry if i'm not using google for this.. i really want to get answers from people in this forum. this will give me some idead how it really works

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.