I have a strange case where a script should receive the values of 2 parameters every now and then. One of the parameters is geo and the other one is tids and I have to explode tids to 4 different variables for my use. I would like to setup a condition where geo parameter may be always present in the requested url and tids may not be. Would that be possible with OR operator "||"? For now I have
if (isset($_GET['tids']) || isset($_GET['geo'])) {
$tidsexplode=$_GET['tids'];
$pieces=explode("separator", $tidsexplode);
$country=$_GET['geo'];
// do what I want with tids exploded $pieces and geo
}else{
// take action as with tid1, tid2, tid3, tid4 and geo location being sent separately in different parameters and their other variables as usual
}
Basically I want to tell the script to act my way, if it is POSTed with parameters tids and geo and if not - process as usual for the separate tids 1, 2, 3 and 4 and geo location are sent in a different way with other parameters. If I try separating them with a comma (,) instead or OR operator (||) that means that all conditions have to be present, i.e. to have tids and geo always sent to the script, else the script won't process if only geo parameter is set. How do I set it to process if geo parameter present but tids may not be? The thing is that some other scripts may pass the data for tid1, 2, 3, 4, etc separately in different parameters tid1, tid2, tid3 and tid, and geo is extracted internally with other variable and from some other sources I get all the tids mixed with a separator together as one string and location as parameter geo. That is why I want to differentiate the cases within the same script without having to copy the same script with different name to distinct the cases and have separate APIs call different file because they have to process data differently.
Aucun commentaire:
Enregistrer un commentaire