dimanche 13 décembre 2015

How to execute common code with multiple condition in php

I am trying to give two or more condition and condition-wise i am try to store a different different values with same variable name and by using that variable i should perform remaining operation(this scorce code is common for each condition). Means from two or more condition only one condition is true at a time then store values in variable(Variable values may different but the variable name is same). and then i execute remaining code by using this variable value. for example see below code to understand what actually i wan't.

<?php
$url=$_SERVER['REQUEST_URI'];
$a="http://www.abcd.com";
$b="http://www.abcd.com?pm";
$c="http://www.abcd.com?cm";

if($url==$a)
{
        $deeplink=1234;
        $mer="hello";
}
if($url==$b)
{
        $deeplink=9090;
        $mer="hru";
}
if($url==$c)
{
        $deeplink="xyz";
        $mer="hru";
}
Remaining code by using $deeplink and $mer variables
(this remainig code is common for all condition but it will take 
$deeplink and $mer value at a time and execute this code)
?>

Aucun commentaire:

Enregistrer un commentaire