What PHP function can be used to highlight and display the source code of a webpage on another webpage?
To highlight and display the source code of a webpage on another webpage, you can use the `highlight_string()` function in PHP. This function takes a string of PHP code as input and outputs it with syntax highlighting.
<?php
$url = 'http://example.com'; // URL of the webpage whose source code you want to display
$html = file_get_contents($url); // Get the HTML source code of the webpage
highlight_string($html); // Display the highlighted source code on the webpage
?>
Keywords
Related Questions
- What are the best practices for handling file paths in PHP code to ensure compatibility between different environments?
- Is it advisable to handle large file uploads using PHP directly, or should an external program be used instead?
- Is it beneficial to initialize variables at the beginning of functions in PHP, or is it sufficient for PHP to do it automatically upon first use?