Title: PHP: IF statement around HTML
Last modified: August 18, 2016

---

# PHP: IF statement around HTML

 *  [Michiel](https://wordpress.org/support/users/michiel/)
 * (@michiel)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/php-if-statement-around-html/)
 * Hi! I am not an PHP expert but managed to get the calendar displayed only when
   the user is in category 1 or the frontpage by using the following:
    <li id=”calendar”
   > <?php if (in_category(1)) get_calendar(); ?>
 * I would like to know how I can change this to the following construction:
    IF
   in category 1 LI command /LI END IF Thanks a lot for you help!!!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/php-if-statement-around-html/#post-82765)
 * use
    echo “LI”; command; echo “/LI”;
 *  Thread Starter [Michiel](https://wordpress.org/support/users/michiel/)
 * (@michiel)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/php-if-statement-around-html/#post-82799)
 * Hi Beel! Thanks a lot (again!). One question still… how do I handle the “” in
   PHP? I have now:
    <?php if (in_category(1)) echo “<li id=””calendar””>”; ?> but
   it does not like the “”… I have been trying to find a solution on php.net but
   did not succeed yet… THANKS!
 *  Thread Starter [Michiel](https://wordpress.org/support/users/michiel/)
 * (@michiel)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/php-if-statement-around-html/#post-82809)
 * Hi Beel! ok! I am not sure yet which key it is as I am working from a finnish
   keyboard but will check on Monday at work.
    I now tried this one (removed the“
   <? ?>” perhaps that works better to post it… php if (in_category(1)) echo “<li
   id=””calendar””>”; I still get the error : Parse error: parse error, unexpected
   T_CONSTANT_ENCAPSED_STRING, expecting ‘,’ or ‘;’ in /home2/…/public_html/blog/
   index.php on line 112
 *  Thread Starter [Michiel](https://wordpress.org/support/users/michiel/)
 * (@michiel)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/php-if-statement-around-html/#post-82812)
 * Beel, nevermind the above to posts…. IT WORKS 🙂 Thanks!!!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP: IF statement around HTML’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [Michiel](https://wordpress.org/support/users/michiel/)
 * Last activity: [21 years, 10 months ago](https://wordpress.org/support/topic/php-if-statement-around-html/#post-82812)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
