get_called_class hack not working with eval-code.

Posted by Ekampp on Stack Overflow See other posts from Stack Overflow or by Ekampp
Published on 2010-06-13T23:05:20Z Indexed on 2010/06/13 23:12 UTC
Read the original article Hit count: 224

Hi there.

I am using a ge_called_class hack for allowing late static binding in php version 5.2 (found here).

I have the following in my code:

# db_record.php
$ac = "ForumThread";
$objects = $ac::find("all");

This will not work in php 5.2 for some reason, so I have done this:

# db_record.php
$ac = "ForumThread";
eval("\$objects = {$ac}::find('all');");

This on the other hand will not work with the get_called_class function. I get an error that the file function can't read the evaled section of code.

So how do I solve this problem?

Best regards.

© Stack Overflow or respective owner

Related posts about php5

Related posts about eval