PHP Switch statements Error -


i made site , added pm thing , when go pm.php gives me error:

fatal error: switch statements may contain 1 default clause in /home/vol10_3/hidden.com/hidden/htdocs/includes/classes/pm.class.php on line 673

code:

    function get_new_messages($uid=null,$type='pm')     {         if(!$uid)             $uid = userid();         global $db;         switch($type)         {             case 'pm':             default:             {                 $count = $db->count(tbl($this->tbl),"message_id"," message_to '%#$uid#%' , message_box='in' , message_type='pm' ,    message_status='unread'");              }             break;              case 'notification':             default:             {                 $count = $db->count(tbl($this->tbl),"message_id"," message_to '%#$uid#%' , message_box='in' , message_type='notification' , message_status='unread'");             }             break;         }          if($count>0)             return $count;         else             return "0";     } } 

you don't use brackets or default that.

<?php  switch ($type) {     case 'pm':         // when $type 'pm'         // can multiple statements         break;      case 'notification':         // when $type 'notification'         // can multiple statements         break;      default:        // else        break; } 

you add default once, code execute if none of other cases executed. "case: 'pm':" section starting block go until break statement exits it. if there no break statement enter next block (in case notification).

here's link php's website has more examples , details how statements work.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -