|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Recognising code
Hi All,
I'm writing a forum for a PHP site i'm building and would like the facility of users typing in code and the site to be able to recognise the functions in the code. The same way in which this forum works i.e. using the " PHP Code:
The part i'm hazy on is recognising the functions within the specified tags. So my question really is, how do i compare elements in a string to PHP/JSP/ASP/Java/C++ and C functions? All help is greatly appreciated... Cheers, Harvey |
|
#2
|
||||
|
||||
|
Your best answer to this would be to find a dictionary file already written for each language... I used to use a program called textpad that allowed you to download add-ons that would highlight code based on keywords... I believe these addons were simply text-based... Perhaps they would be of use to you...
Once you have the keyword dictionaries, its just a simple search/replace for the colour coding... |
|
#3
|
|||
|
|||
|
Hi MadCowDzz,
cheers for the tip with textpad. I've been using it for years and never realised all C/C++/Java/HTML/CSS code elements were simply stored in syn files. Great tip!! But unfortunately it doesn't have a PHP file. Does anybody know where I could get this from? Many Thanks, Harvey |
|
#4
|
||||
|
||||
|
textpad's website offers new libraries and addons...
http://www.textpad.com/add-ons/index.html there's a wide variety of languages offered... The php syntax definition in particular is located on this url: http://www.textpad.com/add-ons/synn2t.html (about a third of the way down the page) |
|
#5
|
|||
|
|||
|
Try using highlight_file() function for php..
|
|
#6
|
||||
|
||||
|
highlight_file() would work for the PHP code, but not JSP/ASP/Java/C++ and so on
Its an interesting function though, I didn't know it existed... thanks for the post mike_r http://www.php.net/manual/en/functi...hlight-file.php |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Recognising code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|