What best practice should be followed when posting code in a forum thread to ensure readability and understanding by other users?

Issue: One common issue when posting code in a forum thread is that it may be difficult for other users to read and understand, especially if it is not formatted properly. To ensure readability and understanding, it is important to follow best practices such as using proper indentation, commenting the code where necessary, and providing a clear explanation of what the code is intended to do.

// Example PHP code snippet to demonstrate best practices for readability
<?php
// Define a function to calculate the sum of two numbers
function calculateSum($num1, $num2) {
    $sum = $num1 + $num2;
    return $sum;
}

// Call the function with two numbers and output the result
$number1 = 5;
$number2 = 10;
$result = calculateSum($number1, $number2);
echo "The sum of $number1 and $number2 is: $result";
?>