|
Posted by sam on 11/16/05 23:57
> define(DATABASE_CLASS, MySQL_5_Database);
There is nothing wrong with this line
> $db = new DATABASE_CLASS($user, $pwd, $dbName);
Here php looks for class named DATABASE_CLASS because
of the new keyword and not for the contain of DATABASE_CLASS.
> Fatal error: Class 'DATABASE_CLASS' not found in
> C:\wwwroot\eclipse\workspace\cpim\index.php on line 21
That's why you get this error.
> Is there some way of using more C-style preprocessor substitution, to
> make something like this possible?
Yes:
define(DATABASE_CLASS, MySQL_5_Database);
..
..
..
$class_name = DATABASE_CLASS;
$db = new $class_name ($user, $pwd, $dbName);
Now, PHP knows that $class_name is a variable that contains the name of the
class.
That why it should work.
[Back to original message]
|