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

  • SEARCH
  • Home
  • 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 8526171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:11:49+00:00 2026-06-11T08:11:49+00:00

I have a problem, Ive been making my own MVC app but there seems

  • 0

I have a problem, Ive been making my own MVC app but there seems to be a problen in passing variables between model and controller. Output from controller is a single variable containing some json format data and it looks simple.

Controller

<?php 

class controllerLib 
{
     function __construct() 
     {
            $this->view = new view();
     }

     public function getModel($model) 
     {
            $modelName = $model."Model"; 
            $this->model=new $modelName();
     }
}

 class controller extends controllerLib
 {
     function __construct()
     {
            parent::__construct();
     } 

     public function addresses($arg = false) 
     {
            echo'Addresses '.$arg.'<br />';

            $this->view->render('addressesView');

            $this->view->showAddresses = $this->model->getAddresses(); 
     }
 }

 ?>

View

 <?php 

 class view
 {
    function __construct()
    {
    }

    public function render($plik)
    {
        $render = new $plik();
    }
 }

 class addressesView extends view
 {
    public $showAddresses;

    function __construct()
    {
        parent::__construct();

        require 'view/head.php';

        $result = $this->showAddresses;


        require 'view/foot.php';
    }
 }


 ?>

Now problem is that $this->showAddresses does not pass to view and im stuck.

  • 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-06-11T08:11:50+00:00Added an answer on June 11, 2026 at 8:11 am

    The code have various issues:

    1. render() save the new View in a local var so that don’t exists after the function end

    2. You can’t expect $this->showAddresses to have a value at the constructor time.

    You should implement the render() method as a method outside of the View constructor.

    function __construct() 
    {
        parent::__construct();
    
        require 'view/head.php';
    
        $result = $this->showAddresses; // (NULL) The object is not created yet
    
    
        require 'view/foot.php';
    }
    

    View class:

    public function factory($plik) // Old render($splik) method
    {
        return new $plik();
    }
    

    addressesView class:

    function __construct() 
    {
      parent::__construct();
    }
    
    function render()
    {
        require 'view/head.php';
    
        $result = $this->showAddresses; // Object is created and the field has a value
    
    
        require 'view/foot.php';
    }
    

    Controller class:

     $view = $this->view->factory('addressesView');
     $view->showAddresses = $this->model->getAddresses(); 
     $view->render();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been making changes to my app, but they don't appear when I attempt
I have a problem making the link between the underlying socket (in this case,
I've been having a problem with making sorted lists from dictionaries. I have this
I have this problem I've been trying to tackle for a while. I have
I have a simple problem that I've been stuck on for some time and
I have a homework problem here I've been working on; here is the description:
I have an interesting problem here I've been trying to solve for the last
Here's a tricky iPhone problem I've been working on. I have three UIScrollViews on
I've been playing around with the splitting of atoms and have a problem with
I've been working with R just a few months, I have a problem with

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.