Jump to content

[SOLVED] ? : What do they mean


tallberg

Recommended Posts

hi

 

I have some experience with php but i have not idea what the ? and the : means in the following code.

Please can some one explain.

 

$default_config[$config_name] = isset($HTTP_POST_VARS['submit']) ? str_replace("'", "\'", $config_value) : $config_value;

$new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name];

Link to comment
https://forums.phpfreaks.com/topic/72344-solved-what-do-they-mean/
Share on other sites

You can think of them like an if statement.

 

($expr ? $true_value : $false_value)

 

$expr is some expression that will be evaluated as either true or false.  If it is true, the whole expression in parentheses will evaluate to $true_value.  If $expr is false, the whole expression in parentheses will evaluate to $false_value.

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.