Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3842266
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:46:08+00:00 2026-05-19T15:46:08+00:00

ok what im trying to do is makeing something so i can call it

  • 0

ok what im trying to do is makeing something so i can call it like
$this->model->users->getInfomation('name'); or something similer on my framework
but php give me a strict standards Creating default object from empty value

protected function model($model)
{
    $path = "features". DS ."models". DS . $model .".php";
    require $path;

    $class = 'Model'. ucfirst($model);
    $this->model->$model = new $class;
}

can we make it so it will somehow fit in the standards ?

edit*

this function is in class Application so i can extend them from our controller
like blog Extends Application then call something like $this->model->blog will get something like what im doing above, when i do something like

protected function model($model)
{
    $path = "features". DS ."models". DS . $model .".php";
    require $path;

    $class = 'Model'. ucfirst($model);
    $this->$model = new $class;
}

yes the above code works fine $this->blog->getSomething();, but somehow i want to make them in a group, like the question above, so if we want to get something like $this->model->blog->getSomething();

Thanks for the time.

Adam Ramadhan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:46:08+00:00Added an answer on May 19, 2026 at 3:46 pm

    It’s hard to see what you’re actually doing wrong with that code alone. I’ve made some very simple code to reproduce the error:

    <?php
    $bar = 42;
    $foo = null;
    
    $foo->bar = $bar;
    

    The reason it gives this warning, is that you’re assigning values the “object way”, but you’re assigning it to a variable that isn’t an object. By doing this, the Zend engine actually creates an object for $foo, which is an instance of StdClass. Obviously, 9 out of 10 times, this isn’t what you want to do, so PHP provides a helpful message.

    In your case: $this->model isn’t an object (yet). If you want to get rid of the error, just do:

    if( !is_object( $this->model ) ) {
        $this->model = new StdClass;
    }
    $this->model->$model = new $class;
    

    Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
Trying to get my css / C# functions to look like this: body {
This is a fairly recurring theme on StackOverflow, but once again I can't get
I'm currently trying to implement a StopWatch class. The interface is something like: interface
Trying to make a make generic select control that I can dynamically add elements
Trying to keep all the presentation stuff in the xhtml on this project and
I guess I am missing something quite fundamental and maybe someone can fill me
I have a data grid and in that grid its making this call: <ItemTemplate>
Basically I am trying to call a function (function 1), that get the results
I am trying to use Python (through Django framework) to make a Linux command

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.