⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

Debugging and Code

During application development, the need often arises to display source code directly in the browser, but in a way that is readable (with colors). PHP has built-in tools for this that automatically recognize keywords, strings, and comments, highlighting them accordingly.

EXAMPLE
RESULT
The result will be displayed here...

Overview of Functions for Working with Code

Function Description Example
highlight_file() Reads a file and outputs its content with highlighted PHP syntax. highlight_file("test.php");
highlight_string() Takes a string and outputs it with highlighted PHP syntax. highlight_string($string);
php_strip_whitespace() Returns the code from a file without comments and whitespace. Code minification

1. Displaying Source Code (Highlight)

The highlight_file() and highlight_string() functions use PHP's built-in color schemes. This is extremely useful if you want to display code examples on your website without having to manually write <span> tags for each color.

2. Minification (php_strip_whitespace)

When code goes into production, we sometimes want to reduce file sizes. This function removes all comments and empty lines, making the code less readable for humans but faster for the compiler to parse.