Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Books
Software
Downloads
Hosting
manuals
Forums
Script directory
Training
Our Links

ADD TO Progged Progged
ADD TO DEL.ICIO.US Del.icio.
ADD TO DIGG Digg
ADD TO FURL Furl
ADD TO NEWSVINE Newsvine
ADD TO NETSCAPE Netscape
ADD TO REDDIT Reddit
ADD TO STUMBLEUPON StumbleUpon
ADD TO TECHNORATI FAVORITES Technorati
ADD TO SQUIDOO Squidoo
ADD TO WINDOWS LIVE Windows Live
ADD TO YAHOO MYWEB Yahoo MyWeb
ADD TO ASK Ask
ADD TO GOOGLE Google
ADD TO MAGNOLIA Magnolia
ADD TO SPURL Spurl



 
 

SPONSORS



 
 

Syntax highlighted code

Have you ever wanted to display your PHP code examples but wanted to display them syntax highlighted . The colors are defined with the built in syntax highlighter in php . Lets look at the code and then see an example .

Code :

<?php
function sourcecode($url)
{
//clear file stat cache
clearstatcache();
//if the file doesnt exist
if(!file_exists($url))
{
return 1;
}
//open the url
$fp=fopen($url,"r");
//get the size of the url
$size=filesize($url);
//store in the temp variable
$temp=fread($fp,$size);
//display color coded syntax highlighting
$coloredcode=highlight_string($temp);
return 0;
}
//call the function with a url
sourcecode("gdsample1.php");
?>

Example :