How can the issue of a webpage going haywire be resolved when trying to include a PHP script?

The issue of a webpage going haywire when trying to include a PHP script can be resolved by ensuring that the PHP script is properly formatted and does not contain any errors. Additionally, make sure that the file extension is correct (.php) and that the PHP code is enclosed within <?php ?> tags. Lastly, check for any syntax errors or missing semicolons in the PHP script.

&lt;?php
// Your PHP code here
?&gt;