Jump to content

calling class help needed.


spires

Recommended Posts

Hi

 

How do I turn this:

if($LCname=='Business_solutions'){
 $newChild  = Business_solutions::find_by_id(1);
}

 

In to something like this:

$newChild  = $LCname::find_by_id(1);

 

 

I'm calling lots of class's, and want to make it more dynamic.

The 2nd example would be perfect, but that does not work.

 

Is there an alternative?

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/236336-calling-class-help-needed/
Share on other sites

Hi, Thanks for your help.

 

I've not come across that before.

 

I'm trying:

if (in_array($LCname, array("Business_solutions_cat"))) { // for security
    $newChild = call_user_func($LCname . "::find_by_id", 1);
foreach($newChild as $newChilds){
	echo $newChilds->id;
}
}

 

but nothing is echoing. Am I missing some code?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.