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 8464223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:40:43+00:00 2026-06-10T14:40:43+00:00

I am newbie in Zend framework.And i have made sample project in netbeans.And it

  • 0

I am newbie in Zend framework.And i have made sample project in netbeans.And it is working properly displaying index.phtml .But , I need to call my controller.What I have tried is below.

IndexController.php


<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {

    }

    public function indexAction()
    {
        firstExample::indexAction();
    }    

}

And I have deleted all the content of index.phtml(just a blank file) , coz i don’t want to render this view.
My custom controller is:

firstExampleController.php

<?php
class firstExample extends Zend_Controller_Action{
    public function indexAction(){
        self::sum();
    }

    public function sum(){
        $this->view->x=2;
        $this->view->y=4;
        $this->view->sum=x + y;
    }
}
?>

firstExample.phtml

<?php
echo 'hi';
echo $this->view->sum();
?>

How to display sum method in firstExample.php.

It just shows blank page after hitting below URL.

http://localhost/zendWithNetbeans/public/

I think after hitting on above URL , execution first goes to index.php in public folder.And I didn’t change the content of index.php

  • 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-10T14:40:45+00:00Added an answer on June 10, 2026 at 2:40 pm

    You are using controller (MVC) incorrectly, Controller should not do any business logic, in your case sum method. Controller only responsible controlling request and glueing model and view together. That’s why you have problems now calling it.

    Create Model add method sum, and use in any controller you want. From controller you may pass model to view.

    Here is example: http://framework.zend.com/manual/en/learning.quickstart.create-model.html it uses database, but it’s not necessary to use with database.

    Basically your sum example could look like:

    class Application_Sum_Model {
    
     public function sum($x, $y) {
       return ($x + $y);
     }
    }
    
    class IndexContoler extends Zend_Controller_Action {
    
       public function someAction() {
    
        $model = new Application_Sum_Model(); 
    
        //passing data to view that's okay
        $this->view->y   = $y;
        $this->view->x   = $x;
        $this->view->sum = $model->sum($x, $y); //business logic on mode
    
       }
    }
    

    Please read how controller is working, http://framework.zend.com/manual/en/zend.controller.quickstart.html

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

Sidebar

Related Questions

As a newbie of Zend framework, I have a few version-dependent questions on the
A total newbie question I know. I'm sing Zend framework, and sending an array
I am newbie in zend framework , a simple question : in my IndexController
I am a newbie to the Zend Framework. I just finished installing Zend Server
First of all I am a newbie. I installed zend framework in my wamp
I am a newbie of Zend Framework. I downloaded the Zend Framework and then
Newbie question here but for some reason I cant figure this out. I have
Newbie in javascript.. Need a little help. I have a SPAN or IMG that
I am a newbie with zend-framework and I am building a small application.. Everything
I am using zend Framework Form, I am newbie in zend Framework and i

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.