Tag: php

PHP Extension php_exif

If you are running Apache 2.2.4 on Windows Server and try to load php_exif.dll in your php.ini file, this can cause Apache to not restart. The fix is pretty simple. You have to load php_mbstring.dll before php_exif.dll. For some reason, the default php.ini has exif listed before mbstring, which results in killing Apache on Windows.

My working set of extensions that I uncomment are:

  • extension=php_mbstring.dll
  • extension=php_exif.dll
  • extension=php_gd2.dll
  • extension=php_gettext.dll
  • extension=php_mcrypt.dll
  • extension=php_mysql.dll
  • extension=php_tidy.dll

This works for me on Windows Apache 2.2.4 and PHP 5.2.3.

Filed under: ApacheTagged with: , , ,

Use PHP To Display Elements

Here is something which I wanted to do with WordPress for a while now. In the sidebar, I wanted to remove the ecommerce seals for the SSL certificate and PayPal from the main blog entries and only have them display for the WordPress Pages. This is where The WordPress Codex comes in handy and explains how WordPress Conditional Tags can be used to display content based on what page the reader is currently viewing. There is even a code sample for the sidebar.

In my case, though it was really simple, I just added the html code for the gifs into a php section, similar to this:

<?php if (is_page()) {
    echo "<img src="http://www.site.com/logos/paypal.gif" />";
    }
?>

However note, that this code will not work! If you notice, that the echo statement uses double-quotation marks and that the html code does as well, you will realize that in order for this code to work, you have to escape the quotation marks in the html by using the backslash.

Therefore the correct code would look like this.

<?php if (is_page()) {
    echo "<img src=\"http://www.site.com/logos/paypal.gif\" />";
    }
?>

The is_page tag is used in this case to mean that if I am on a WordPress Page, then include the html in the echo command. To add more html code, I would just add another echo command, making sure I enclosed it in quotes, and that I escaped any quotes in the html with a backslash, and finally in PHP, you have to end each command with a semicolon.

For further information on conditional tags see the WordPress Codex.

Filed under: WordPressTagged with: , , , , , , ,