PHP Switch statement error
<?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 echo
es.
精彩评论