How can formatting issues be avoided when copying and pasting code into a PHP forum thread?

When copying and pasting code into a PHP forum thread, formatting issues can be avoided by using code blocks or the preformatted text option provided by the forum. This preserves the indentation and spacing of the code, making it easier for others to read and understand. Additionally, ensuring that the code is properly formatted before copying and pasting can help prevent any issues.

<?php
// Example PHP code snippet
echo "Hello, World!";
?>