Posting PHP codes on blog.

If you want to post PHP code on blog or any web page then its easy. Use the command:-

php -s /path/to/your/php/script > The_Code_to_post

This will generate a html code that you can directly paste in the web page’s code to display your code with syntax highlighting, but if you post this code in Blogger.com or Drupal then you will notice extraneous blank lines after every line of your code. This is due the fact that Blogger.com and Drupal insert a line break themselves whenever they encounter a new-line or carriage-return. To fix this problem, use the following command instead of the above one.

php -s /path/to/your/php/script | tr -d ‘\n\r’ > The_Code_to_post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.