I am reading some PHP code that I could not understand:
class foo {
function select($p1, $dbh=null) {
if ( is_null($dbh) )
$dbh = $this->dbh
What is the value of $this->dbh
It will have the default value, if assigned else "null"
Is it a local variable for function select()? If it is, then why get() function can use this variable?
It is the property of foo class, not the local variable, so it will be available to all the methods of the foo class
Does it belongs class foo's data member? If it is, why there is no declaration for $dbh in this class?
Yes it does belong to the foo's data member, you don't see any declaration because, PHP is not strict about requiring class property declarations.