In what scenarios would it be more beneficial to use the "highlight_string" function instead of custom highlighting methods in PHP scripts?

When you need a quick and easy way to highlight syntax in PHP scripts, using the built-in "highlight_string" function can be more beneficial than creating custom highlighting methods. This function automatically formats PHP code with HTML syntax highlighting, making it useful for displaying code snippets on websites or in documentation. It saves time and effort compared to manually creating highlighting logic.

<?php
$code = '<?php echo "Hello, World!"; ?>';
highlight_string($code);
?>