How to Post Source Code?!

It will be cool right if we can add the source code of any programming language in this blog… Do you know how to do it?!! Ok.. Actually this trick is given by wordpress perhaps some of us not realize this thing…

[sourcecode language=’php’]
$host=”localhost”;
$username=”root”;
$password=”";
$databasename=”KTCI_DATABASE”;
$link=mysql_connect($host, $username, $password) or die(”Database is not connected!”);
$selectdb = mysql_select_db($databasename, $link)or die(”Database is not selected!”);
?>
[/sourcecode]

Wrap your code in these tags: [sourcecode language=’css’]…[/sourcecode]. You can replace the language with “css” with the language that you’re writing in. Currently we support syntax highlighting for the following language codes:

* cpp
* csharp
* css
* delphi
* java
* jscript
* php
* python
* ruby
* sql
* vb
* xml

The language attribute is required! If we don’t have what you need pick the closest.
Code in between the [sourcecode] tags will automatically be encoded for display, you don’t need to worry about HTML entities or anything.
 
Copyright © 2011 Blogger with Love | Themes by Edit-me.