Welcome to PHP4IT
Main Menu
· Main Page
· Account Settings
· Forum
· Recommend Us
· Contact


Search


Solutions Categories
· All topics
· Database Import and Conversion with PHP (Feb 07, 2006)
· PHP Security (Mar 28, 2008)
· Printing (Jan 05, 2006)
· Windows PHP Solutions (Apr 04, 2008)


PHP4IT RSS Feed
Add the PHP4IT RSS Feed to your favorite RSS news reader!

  
PHP4IT Forum Index

Post new topic   Reply to topic
View previous topic Log in to check your private messages View next topic
<-- Vote this topic thumbs up or down
Author
nw
Post subject: Code highlighting?  PostPosted: Jan 17, 2006 - 07:12 AM PST
Guest










Maybe it worth to highlight code in your articles?
 
   
Reply with quote Back to top
DavidOffline
Post subject:   PostPosted: Jan 17, 2006 - 06:17 PM PST
Site Admin


Joined: Apr 18, 2005
Posts: 23

Reputation: 28Reputation: 28Reputation: 28
Status: Offline



Thanks for the suggestion- I've added the feature. I had to write a little function so that the whole article is not highlighted- rather it looks for "<php and ?>?;" and just highlights the PHP code. Here's the code if anyone's interested:

function find_and_highlight_php_code($html)
{
if (!strstr($html, '<?php')){
return $html;
}
$t = explode('<?php', $html);
$out = '';
foreach ($t as $tt){
if (!strstr($tt, '?>')){
$out .= $tt;
}else{
$tt = explode('?>', $tt);
$out .= highlight_string('<?php' . $tt[0] . '?>', TRUE) . $tt[1];
}
}
return $out;
}
 
 View user's profile Send private message  
Reply with quote Back to top
MedwooduOffline
Post subject:   PostPosted: Jan 19, 2006 - 06:18 AM PST



Joined: Jan 17, 2006
Posts: 1
Location: Moscow

Status: Offline



highlight_file("script.php");
 
 View user's profile Send private message  
Reply with quote Back to top
DavidOffline
Post subject:   PostPosted: Jan 19, 2006 - 11:54 AM PST
Site Admin


Joined: Apr 18, 2005
Posts: 23

Reputation: 28Reputation: 28Reputation: 28
Status: Offline



It's not as simple as that- all the html tags would be converted- I just wanted the stuff between "<?php" and "?>" to be highlighted.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
Go To the Top of the ThreadGo Home
All times are GMT - 8 Hours
Post new topic   Reply to topic
View previous topic Log in to check your private messages View next topic
View previous topic
>View next topic
-->