Jump to content

[SOLVED] Code Tags


proggR

Recommended Posts

Does anybody know how the code tags work? How do they get parsed and formatted with the colors like they do? I want to include something to the same effect onto my website eventually but I'll also be using other languages so I'll likely need more than one parser.

Anyway, if anyone knows it would be really helpful.

 

<?php
echo "How does it know?!";
?>

Link to comment
https://forums.phpfreaks.com/topic/113907-solved-code-tags/
Share on other sites

Basically, regular expressions are used to detect certain characters/tags in text and gets the value in between them. Depending on which tag is used, the HTML is appropriately formatted. This also helps prevent XSS, and Injections too, by not allowing the user to directly enter HTML tags.

Link to comment
https://forums.phpfreaks.com/topic/113907-solved-code-tags/#findComment-585326
Share on other sites

Oh I understand that part of it. I was just wondering how the code tags themself are formatted. I understand that bold tags with []would put bold tags with <> around the text and an image tag with [] would format it with the <>. But what tells the tags how to format variables and functions and strings the way that it does, wigh the different colors. I could easily format my code in the font thats used and in the box with a separate colored background. But how does it know to make "echo" green and the string red? Does it compare each and every word with a list?

Link to comment
https://forums.phpfreaks.com/topic/113907-solved-code-tags/#findComment-585331
Share on other sites

Thanks much, thats exactly what I was looking for.

Do you know if there is anything like that for other languages like Java or C that would format them in a similar way? I know I've seen them formatted so there must be something.

 

And just as a Pee Ess:

I must admit, I'm fairly new to PHP. Two months ago I hadn't even looked at it. Everyday that I work with it, though, I'm more and more impressed with the amount of options and accessibility.

Link to comment
https://forums.phpfreaks.com/topic/113907-solved-code-tags/#findComment-585348
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.