What are the differences between the IF function and the echo operator in PHP, and how should they be properly used?

The IF function in PHP is used to perform conditional checks and execute different blocks of code based on the result of the condition. On the other hand, the echo operator is used to output data to the browser. The IF function should be used when you need to make decisions based on certain conditions, while the echo operator should be used to display information to the user.

// Example of using IF function
$number = 10;
if ($number > 5) {
    echo "Number is greater than 5";
}

// Example of using echo operator
$name = "John";
echo "Hello, " . $name;