FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » the ? operator
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
the ? operator [message #5472] Tue, 03 September 2002 22:58 Go to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
i see this type of statement used quite often in the fudforum code:

$msg_subject = ( !preg_match('/^{TEMPLATE: reply_prefix}/i', $subj) ) ? '{TEMPLATE: reply_prefix}'.$subj : $subj;


since i am still fairly new to php (picking it rather quickly since it is quite a lot like C/C++) i dont quite understand this statement. what is being with the '?' here? also what is the ': $subj'?

(this is just a sample line from another thread on the board)
Re: the ? operator [message #5473 is a reply to message #5472] Tue, 03 September 2002 23:48 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
This is a more compact way of doing an if() { } else { } condition, which is used in C quite often.
The code you've shown, is indentical to:
if( !preg_match('/^{TEMPLATE: reply_prefix}/i', $subj) ) {
   $msg_subject = '{TEMPLATE: reply_prefix}'.$subj;
} else {
   $msg_subject = $subj;
} 



FUDforum Core Developer
Re: the ? operator [message #5477 is a reply to message #5472] Wed, 04 September 2002 02:43 Go to previous message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
ok that makes much more sense than what i was thinking of
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: PHP-Upgrade to V4.2.x
Next Topic: help
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 17:08:01 GMT 2024

Total time taken to generate the page: 0.02662 seconds