What is the significance of using an underscore at the beginning of a variable in PHP?

Using an underscore at the beginning of a variable in PHP is a common convention to indicate that the variable is meant to be private or protected. This helps developers easily identify and distinguish between public and private variables in a class, making the code more readable and maintainable.

class MyClass {
    private $_privateVar;
    
    public function setPrivateVar($value) {
        $this->_privateVar = $value;
    }
    
    public function getPrivateVar() {
        return $this->_privateVar;
    }
}