PHP Code

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
deelliiaa
Forum Newbie
Posts: 1
Joined: Thu Oct 28, 2010 5:10 pm

PHP Code

Post by deelliiaa »

I am new to this forum and very new to code in general. I have a code that hides a block of text if a user is not logged into our site:

if( !empty($_SESSION['user'])

what I need is a code that will hide a different block of text if a user IS logged in.

Any help would be appreciated...
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP Code

Post by Jonah Bron »

The opposite of

Code: Select all

if( !empty($_SESSION['user']))
would be

Code: Select all

if( empty($_SESSION['user']))
The exclamation mark indicates "not" or "the opposite of".
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: PHP Code

Post by mikosiko »

or maybe make more sense (at least for me) :wink: :

Code: Select all

if( !empty($_SESSION['user'])) {
  // here the code that hide text block 1.... user logged
} else {
  // here the code that hide text block 2.... user not logged
}
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP Code

Post by Jonah Bron »

Yes, that works too... but they're not necessarily in the same place.
Post Reply