I need help making something like this.
so for example
if ($number == NULL) {
echo 'there is a $number';
}
else {
echo 'There is no value';
}
I need help making something like this.
so for example
if ($number == NULL) {
echo 'there is a $number';
}
else {
echo 'There is no value';
}
Doesn't look like you need any help at all.... your "example" is already perfectly valid PHP code. (Granted, you won't get to see the actual number since you used single quotes, meaning variable interpolation won't be done.)
Thanks dude! Much appreciated.
Also you may want to use [man]is_null[/man] but you don't have to as brad pointed out your code is valid.
Derokorian;11012423 wrote:Also you may want to use [man]is_null[/man] but you don't have to as brad pointed out your code is valid.
is_null better practice because if it is i will use Thanks!
Apparently 10am is still too early in the morning for me. For starters, your logic was reversed... you claim "there is a $number" when that variable is NULL, but I think you wanted the opposite (unless your goal is to lie to the user?).
Furthermore, because you didn't use the '===' identical operator, note that values such as the empty string, FALSE, the integer zero, or the floating point number 0.0 will all claim that "There is no value" (even though one or more of those are potentially perfectly valid values).
(Also note that I personally would never use is_null() here since I would instead first think to use the aforementioned operator instead. "To each his own" applies in that situation.)
So heres what im trying $number it either has a value or it doesnt.. if it does i want it to display a string if it doesnt the i want it to display a "die" message am i making any sense... lol im not sure anymore
if (isset($number))
{
echo "Variable is set";
}
else
{
echo "its not set";
}
But what does "has a value" mean? In your code above, you've gone from comparing values to checking if the variable has simply been defined (which would include situations where it was defined as NULL).
its was backwards this is what im using which is working.
if ($mainHandid == NULL) {
$template_hook['forumhome_above_forums'] .= "". $missingitem ."";
}
else
{
$template_hook['forumhome_above_forums'] .= "". $itemmainHand ."";
}
[code]