Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.