PHP if/else statement

前端 未结 6 363
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-20 23:29

I\'m a complete newbie to PHP but found it can be very useful. How can I write the following statement in PHP:

If body ID = \"home\" then insert some html, e.g.

6条回答
  •  一整个雨季
    2021-01-20 23:54

    You can try using this :

    $html = '';
    if ( $body_id === 'home' )
    {
        $html .= '

    I am home!

    '; } else { $html .= '

    I\'m not home.

    '; } echo $html;

    This will echo the html code depending on the $body_id variable and what it contains.

提交回复
热议问题