View Full Version : not to display string if variable is null.
demo7up
09-07-2012, 01:05 PM
I need help making something like this.
so for example
if ($number == NULL) {
echo 'there is a $number';
}
else {
echo 'There is no value';
}
If the variable is set to null when there is no value, then I think you could check it by using $number === null (three '='). If the variable is not set at all when there's no number then it won't be equal to null so you'd have to use isset($number) to see if it's set.
demo7up
09-07-2012, 01:14 PM
i think i got it
i think i figured it out
Is this correct?
if (isset($number))
{
echo "Variable is set";
}
else
{
echo "its not set";
}
Yeah, that will work if the variable isn't set at all when there's no number.
demo7up
09-07-2012, 01:24 PM
Yeah, that will work if the variable isn't set at all when there's no number.
Thanks for your help man.. Its for a vb plugin im coding n00b coder.. Very much appreciated.
--------------- Added 1347032342 at 1347032342 ---------------
one more question...
how would i go about adding the if/else in this
$template_hook['forumhome_above_forums'] .= "".
I think i got it i will post back if it worked
--------------- Added 1347034575 at 1347034575 ---------------
nope i tried this ty u guys for you patience with me..
$template_hook['forumhome_above_forums'] .= "".if (isset($shirtid)) {
echo $itemshirt;
}
else
{
echo "put a shirt on";
}."
</div>"; }
--------------- Added 1347036110 at 1347036110 ---------------
okay so i give up here is my plugin Whats wrong here????
$shirtid = "". $decode[items][shirt][id] ."";
$itemshirt = "<a href=\"http://www.wowhead.com/item=".$shirtid."\" rel=\"item=".$shirtid."\"><img class=\"wowequipimg\" src=\"".$bliziconurl."/".$shirticon.".jpg\"></a>";
if (isset($shirtid)) {
$template_hook['forumhome_above_forums'] .= "". $itemshirt ."";
}
else
{
$template_hook['forumhome_above_forums'] .= "put a shirt on";
}
--------------- Added 1347036382 at 1347036382 ---------------
Getting Close i can feel it...
im not getting any errors but
This works! I tested
if (isset($shirtid)) {
$template_hook['forumhome_above_forums'] .= "". $itemshirt ."";
}
This isnt though
else
{
$template_hook['forumhome_above_forums'] .= "put a shirt on";
}
I just get an X missing image icon instead of displaying the above msg
--------------- Added 1347036765 at 1347036765 ---------------
End Result Which works!!!!
if ($shirtid == NULL) {
$template_hook['forumhome_above_forums'] .= "". $missingshirt ."";
}
else
{
$template_hook['forumhome_above_forums'] .= "". $itemshirt ."";
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.