Sign in to follow this  
Evil Steve

[web] PHP C++ parser?

Recommended Posts

You can attempt to use the Highlight File function. It's made for PHP but it might also work for C++.

Here's a little function/file I wrote up to output it nicely:


// Title: PHP Source Code Display
// Author: Rob Loach (
// Description:
// A script which just displays the source of the
// given file.

// The file to display
$file = "/file.php";

// Extensively checks if a file exists
function file_exists_incpath ($file)
$paths = explode(PATH_SEPARATOR, get_include_path());
foreach ($paths as $path)
$fullpath = $path . DIRECTORY_SEPARATOR . $file;
if (file_exists($fullpath)) {
return true;
return false;

// See if the file exists
if (file_exists_incpath($file)){

// Display the source
echo "<h1>Source View</h1><p>Source of <a href='$file' target=_blank>$file</a>:</p>
<hr/><code>" .
highlight_file("$file", true) .
"</code><hr /><p>Processed: " .
date("F j, Y g:i:s a", time()) .
} else{
echo "<h1>Source View</h1><p>The given file does not exist (<a href='$file' target=_blank>$file</a>).</p>";



Share this post

Link to post
Share on other sites
Original post by DerAnged
It just does not yet parse c++, or c++ keywords sutch as class.

I'm currently working on a C++ language file for Geshi. It doesn't have everything in it as C++ is just such a huge language, but it has the basic stuff. Still in construction. If you guys have anything to add to it, please help me out and tell me.

[Demo] [Source] [Download]

You have to put the file in the geshi directory and then set $language to "cpp" when you're using it.

Originally from the Geshi Forums
The following languages from your list will already be supported in 1.0.2:

Assembly (NASM)

In addition, some of the languages you list above, like Transact-SQL, can be substituted for by the plain SQL file.

Also, some other languages you've missed, like Bash and VisualFoxPro will be supported.

Well, until then, mine'll work [wink].

[Edited by - Rob Loach on October 20, 2004 2:11:29 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this