i would like to create a php function. Basically, that's what i've :
if(isset($myvariable) AND $myvariable == "something")
{
echo 'You can continue';
}
and that's what i want :
if(IssetCond($myvariable, "something"))
{
echo 'You can continue';
}
I want function that tests if the variable exists, and if it does it tests if the condition is respected. Otherwise it returns false.
I've tried a lot of things, but i still have a problem when $myvariable doesnt exist.
function IssetCond($var, $value){
if(isset($var) AND $var == $value)
{
return true;
}
else
{
return false;
}
}
When $myvariable exists and whether the condition is respected or not, it works.
If you have some minutes to help me i'll be grateful.
Thanks
Thomas
You can pass just the name, not the var, and use variable variable
function IssetCond($var, $value){
return (isset($$var) AND $var == $value);
}
Used like
if(IssetCond('myvariable', "something"))
{
echo 'You can continue';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With