1

I initialize class objects something like this and it works.

$obj = new Model_Person_DbTable();

But when do it like this:

$className = 'Model_Person_DbTable()';
$obj = new $className;

Then it show following fatal error:

Model_Person_DbTable() class not found.

How can I achieve this in PHP/Zend

1
  • 2
    $className = 'Model_Person_DbTable';$obj = new $className(); Commented Feb 9, 2011 at 11:51

1 Answer 1

4

Try without the brackets (they are not part of the class name)

$className = 'Model_Person_DbTable';

If that doesnt help, make sure your autoloader and include path is set up correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.