[SOLVED]Why wont this if (isset($strlvl)) code work?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

[SOLVED]Why wont this if (isset($strlvl)) code work?

Post by Mythic Fr0st »

Well im trying to develop a little stat system thingy, but...

it wont let me use isset to check if it has been set or not

Code: Select all

if (isset($strlvl))
{
echo 'boo';
}
else
{
$strlvl=4;
}
can you see my error? oh, and if you can fix it, how where do I put the ! so its like

if (!isset($strlvl)) so its saying if its false

- Thanks

NVM I cant belive I didnt notice, it was the wrong line lolz
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

What is it not doing that it's supposed to do? If the isset is never returning false, it may be that you are evaluating an initialized string (that is storing boolean false, the integer zero, or an empty string), and not an uninitialized variable that represents NULL. isset will only return false if the variable has not yet been initialized, or is equal to NULL. Try using empty if you just want to check if the variable returns false.
Post Reply