i am a new comer to php. I discovered this syntax in wordpress. Can anybody show me the final type of that code?

$page = $_SERVER['REQUEST_URI'];
$page = str_replace("/","",$page);
$page = str_replace(".php","",$page);
**$page = $page ? $page : 'default'** 

the final line(bolded). thanks

This is the so-known as conditional operator. It truely does work as an if-else statement, so

$page = $page ? $page : 'default';

does just like

if($page)
{
    $page = $page;
}
else
{
    $page = 'default';
}

This means when the $page variable isn't empty then assign the $page variable around the last line that variable or place it to 'default' page title.

It is called conditional operator

This means when $page hasn't value (or it's zero), place it to 'default'.

more verbose syntax from the last line:

if ($page)
{
    $page = $page;
}
else
{
    $page = 'default';
}

It is a ternary operation which isn't PHP or Wordpress specific, it is available in many langauges.

(condition) ? true_case : false_case 

So within this situation the need for $page is going to be "default", when $page is something such as false — Otherwise it'll remain unchanged.

This is the conditional operator: http://php.net/manual/en/language.operators.comparison.php

That line means

if($page)
    $page = $page;
else
    $page = 'default';

It's a good example of the conditional operator in PHP.

It is the shorthand version of:

if( something is true ){
    do this
}else{
    do that
}

http://www.totallyphp.co.uk/tutorials/using_if_else_ternary_operators.htm http://php.net/manual/en/language.operators.comparison.php