Sunday, August 12, 2007

How to paste good formatted php source code on blogger?

Several days ago, I just wanted to paste some php codes on this blog. But the codes I pasted was ugly. Then I decided to write something to format the looking. It is finished today.

The formatted codes:

<?php

//creates a unique id with the 'about' prefix
$a uniqid(about);
echo 
$a;
echo 
"<br>";

//creates a longer unique id with the 'about' prefix
$b uniqid (abouttrue);
echo 
$b;
echo 
"<br>";

//creates a unique ID with a random number as a prefix - more secure than a static prefix 
$c uniqid (rand(), true);
echo 
$c;
echo 
"<br>";

//this md5 encrypts the username from above, so its ready to be stored in your database
$md5c md5($c);
echo 
$md5c;
echo 
"<br>";

?>


Two steps to paste your nice looking php code on your blog.

1. Visit http://phpgoogle.awardspace.com.

2. Submit your code.

3. Copy and paste the HTML source code to your blog.

Yeah, it's very easy.

And the mechanism is very easy too. I just use PHP's Built-in Source Highlighter - highlight_string(). You can read more about it on clicking the link.

I make the online demo to make the thing easy and convenient. Hope it will be useful for you.

1 comment:

Jorge said...

Thanks so much. It was so easy to embed PHP source code on my page.