Using Code Snippets
Displaying Code within a topic often requires special handling to preserve formatting and prevent it from being parsed by the end-user’s client.
Code | |
---|---|
The [code] tag switches to a fixed-width (monospace) font and preserves all spacing. Note: If you have permission to post HTML, it will be parsed. If you do not wish HTML to be parsed, you should surround it with [noparse] tags. | |
Usage: | [code]value[/code] |
Example Usage: | [code]<script type="text/javascript"> <!-- alert("Hello world!"); //--> </script> [/code] |
Example Output: |
Code:
<script type="text/javascript"> <!-- alert("Hello world!"); //--> </script> |
HTML Code | |
The [html] tag allows you to perform syntax highlighting for HTML code. | |
Usage: | [html]value[/html] |
Example Usage: | [html] <img src="image.gif" alt="image" /> <a href="testing.html" target="_blank">Testing</a> [/html] |
Example Output: |
HTML Code:
<img src="image.gif" alt="image" /> <a href="testing.html" target="_blank">Testing</a> |
PHP Code | |
The [php] tag performs the same function as the [code] tag, but also adds syntax highlighting for PHP code. Although it is designed for PHP, it may correctly highlight some other C-like languages. | |
Usage: | [php]value[/php] |
Example Usage: | [php] $myvar = 'Hello World!'; for ($i = 0; \$i < 10; \$i++) { echo $myvar . "\n";} [/php] |
Example Output: |
PHP Code:
|
updated: 2021-10-06 01:30pm | Version: 5.6.5 Alpha 11