开发者

PHP Switch statement error

开发者 https://www.devze.com 2023-03-22 15:51 出处:网络
<?php include \'db.php\'; $mail=$_SESSION[\'session_u_e_mail\']; if(!isset($_GET[\'edit\'])) { $_GET[\'edit\']=0;
 <?php
 include 'db.php';
 $mail=$_SESSION['session_u_e_mail'];
if(!isset($_GET['edit']))
{
$_GET['edit']=0;
}
switch($_GET['edi开发者_开发知识库t'])
{
 case 1: echo "Value";
         break;

 case 2: echo "Value";
         break;

 default: echo "Value";
         break;

 }

I m facing problem that the values in every case is echoed twice.


I've just grabbed the

if(!isset($_GET['edit']))
{
$_GET['edit']=0;
}
switch($_GET['edit'])
{
 case 1: echo "Value";
         break;

 case 2: echo "Value";
         break;

 default: echo "Value";
         break;

 }

this portion and pasted onto codepad and it works fine.

Here is the working version: http://codepad.org/P8bhL5vl

It outputs just "Value".


There is nothing in this code that would even output your default value. No matter the input, this outputs Value. Look in db.php or the files included by it for debugging echoes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号