ohh. sorry. what i intend to write is __autoload function...
http://in.php.net/autoload
moreover __autoload function is highly useful(especially when i hav
one class per file) and i use it nearly every time i use a class.
i dont think the scope of class definition 'included' within a
function is
If you do it that way, you will also have to construct an object and
return it from that function. By including the class definitions
within a function, they will only be available within that function.
You will have to use the function as a factory for building objects.
In most cases I could only
kranthi wrote:
thanks for the comments,
what i m planning to do is
function _autoload($class) {
if($class == 'Database') {
if(class_exis('PDO') {
include_once('Database_PDO.php');
} else {
include_once('Database.php');
}
}
where in Database_PDO.php contains
class Database
thanks for the comments,
what i m planning to do is
function _autoload($class) {
if($class == 'Database') {
if(class_exis('PDO') {
include_once('Database_PDO.php');
} else {
include_once('Database.php');
}
}
where in Database_PDO.php contains
class Database extends PDO {
}
As long as you design it with a consistent interface I don't see a
problem. The whole point of creating abstractions like this is so
when you're writing the rest of your code you don't have to think
about the gritty details behind the scenes (like PDO or non-PDO). If
you design the class so that
5 matches
Mail list logo