Jump to content

[SOLVED] SIMPLE question on PHP syntax


galvin

Recommended Posts

I'm just concerned with the syntax for saying "or" multiple times.  If I have people logging in to my site that all have different a "userid", what is the proper syntax to say "if a userid equals 2 or 6 or 11 or 17, then do this."

 

I thought it would be...

 

if ($_SESSION["userid"] == 2  || 6 || 11 || 17) {

 

}

 

But that doesn't seem to be working.  Do I have to write each one out, as in...

 

if ($_SESSION["userid"] == 2) || ($_SESSION["userid"] == 6) || ($_SESSION["userid"] == 11) || ($_SESSION["userid"] == 17) {

 

}

 

That's fine if I have to write them out like that, but I figured there would be a shorter way to write it.  Please confirm either way.

Thanks,

Greg

Link to comment
https://forums.phpfreaks.com/topic/134663-solved-simple-question-on-php-syntax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.