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

Home » General » PHP discussions » the ? operator
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
the ? operator [message #5472] Tue, 03 September 2002 18:58 Go to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 19: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
add to buddy list
ignore all messages by this user
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] Tue, 03 September 2002 22:43 Go to previous message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
ok that makes much more sense than what i was thinking of
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: PHP-Upgrade to V4.2.x
Next Topic: help
Goto Forum:
  

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

Current Time: Fri Oct 20 13:39:22 EDT 2017

Total time taken to generate the page: 0.00680 seconds