Title: php code widget
Last modified: August 19, 2016

---

# php code widget

 *  [sanstepsan](https://wordpress.org/support/users/sanstepsan/)
 * (@sanstepsan)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/php-code-widget-3/)
 *     ```
       <?php
       $target = mktime(0,0,0,4,7,2011);
       $today = time();
       $difference = ($target-$today);
       $days = (int)($difference/86400);
   
       if ((date('m') == 4) && (date('d') == 7))
       {
       print "<h2>Game On!</h2>";
       }
       else
       {
       print "<h2>$days days to go!</h2>";
       }
       ?>
       ```
   
 * I have the following code which works fine – how do I add html code to make the
   $days in a red font?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/php-code-widget-3/#post-1982827)
 * wrap it in a span either with a css class or an inline style?
 *     ```
       print "<h2><span class="red_days">$days</span> days to go!</h2>";
       ```
   
 * then in style.css:
    `h2.red_days { color: red; }`
 * or
 *     ```
       print "<h2><span style="color: red;">$days</span> days to go!</h2>";
       ```
   
 *  Thread Starter [sanstepsan](https://wordpress.org/support/users/sanstepsan/)
 * (@sanstepsan)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/php-code-widget-3/#post-1982836)
 * Alchymyth
    I tried your second option but as soon as the span is inserted the
   code fails to show anything at all. Could it be because the code is within the
   PHP Code widget?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/php-code-widget-3/#post-1982870)
 * my bad – i need to pay more attention to the quotation marks:
 * `print "<h2><span style='color: red;'>$days</span> days to go!</h2>";`
 * or
 * `print "<h2><span class='red_days'>$days</span> days to go!</h2>";`
 *  Thread Starter [sanstepsan](https://wordpress.org/support/users/sanstepsan/)
 * (@sanstepsan)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/php-code-widget-3/#post-1982890)
 * Alchymyth
 * Single quotes made all the difference.
 * Don’t know why but many thanks.

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

The topic ‘php code widget’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [sanstepsan](https://wordpress.org/support/users/sanstepsan/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/php-code-widget-3/#post-1982890)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
