Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Variables in namespace?
  • This is probably a n00b question, but I was wondering if FUEL (or PHP for that matter) allows for variables in a namespace? Simple example of what I would want to accomplish (code is not working btw):
    // get section info
    $section = Model_Section::find()->where('id', $section_id)->get_one();
    
    // module of section is specified in database
    $module = $section->module;
    
    // get the item through the model, that lives in a module
    // desired result for example: 
    // $item = Blog\Model_Item::find()->where('id', $item_id)->get_one();
    $item = $module\Model_Item::find()->where('id', $item_id)->get_one();
    

    This specific code isn't working, and throws a parsing error (obviously). But it does show the desired result .. Is there a trick to accomplish it?
  • No. But you can use call_user_func() to call a class method using variables, including static calls and namespaces.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion