Should protected/private variables in classes start with $_ in PHP?

In PHP, it is a common convention to prefix protected/private variables in classes with an underscore (_) to indicate their visibility. This helps distinguish them from public variables and serves as a visual cue for developers working with the code. While it is not required by PHP itself, following this convention can improve code readability and maintainability.

class MyClass {
    private $_myPrivateVariable;
    
    public function setMyPrivateVariable($value) {
        $this->_myPrivateVariable = $value;
    }
    
    public function getMyPrivateVariable() {
        return $this->_myPrivateVariable;
    }
}