Reseller Hosting, Shared Hosting, Dedicated Hosting by Vortech Inc.

Go Back   Reseller Hosting, Shared Hosting, Dedicated Hosting by Vortech Inc. > >> General Public > Chit Chat Public
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Chit Chat Public Talk about any thing you want! This forum is public.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-29-2004, 11:36 AM
Brian Brian is offline
Vortech Inc. Customer
Vortech Inc. Customer
 
Location: Ontario, Canada
Can someone explain this syntax...

What does it mean to have two equal signs next to each other?

eg:
Code:
$var1 = $var1==1 ? 3 : 4


and what us the stuff after the ?
Code:
$var1 = $var1==1 ? 3 : 4


Thanks!~
Reply With Quote
  #2  
Old 08-29-2004, 12:39 PM
MEELAN's Avatar
MEELAN MEELAN is offline
Vortech Inc. Customer
Vortech Inc. Customer
 
Location: Roaming
Cool

Here is the answer according my understanding

Code:
If $var1 = 1 then $var1 = 3 else $var1 = 4 end if


Am i correct?
__________________
meelan ;-)

Last edited by MEELAN : 08-29-2004 at 12:42 PM.
Reply With Quote
  #3  
Old 08-29-2004, 06:20 PM
mresell's Avatar
mresell mresell is offline
ePerson
Vortech Inc. Customer
 
Location: Around the \bin
Quote:
Originally Posted by Brian
What does it mean to have two equal signs next to each other?

eg:
Code:
$var1 = $var1==1 ? 3 : 4


and what us the stuff after the ?
Code:
$var1 = $var1==1 ? 3 : 4


Thanks!~

What language Brian?
Is that php? Definitely makes a diff. Most languages follow similiar rules, but the syntax def varies.
Reply With Quote
  #4  
Old 08-29-2004, 06:39 PM
Brian Brian is offline
Vortech Inc. Customer
Vortech Inc. Customer
 
Location: Ontario, Canada
yes, it is PHP. Probably should have indicated that in my 1st post :angel:
Reply With Quote
  #5  
Old 08-29-2004, 07:18 PM
dtay73's Avatar
dtay73 dtay73 is offline
Corn and Basketball !!!
Vortech Inc. Customer
 
Location: Indiana ( USA )
Send a message via ICQ to dtay73 Send a message via AIM to dtay73 Send a message via Yahoo to dtay73
$var = 1 sets the value of $var to 1.
$var == 1 compares the value of $var to 1
Reply With Quote
  #6  
Old 08-29-2004, 07:34 PM
mresell's Avatar
mresell mresell is offline
ePerson
Vortech Inc. Customer
 
Location: Around the \bin
Quote:
Originally Posted by Brian
What does it mean to have two equal signs next to each other?

eg:
Code:
$var1 = $var1==1 ? 3 : 4


and what us the stuff after the ?
Code:
$var1 = $var1==1 ? 3 : 4


Thanks!~

Brian,
If you are going to be coding in php. phpbuilder.org is a good place to start. Lotsof stuff on php. You need a semi colon after that statement or it won't work. Basically, You are assigning a variable then telling it to evaluate that based on the comparison operators on that variable. This is straight out of the manual under comparison operators. This is the newest syntax.

$a == $b Equal TRUE if $a is equal to $b.

Another conditional operator is the "?:" (or ternary) operator, which operates as in C and many other languages.

(expr1) ? (expr2) : (expr3);

This expression evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:16 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Vortech Inc. ©2005
Page generated in 0.37644 seconds with 16 queries
[Output: 60.11 Kb. compressed to 55.86 Kb. by saving 4.25 Kb. (7.07%)]