Zend Framework Forum

Go Back   Zend Framework Forum > Zend Framework Forum > General Talks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-17-2009, 02:28 AM
Junior Member
 
Join Date: May 2009
Posts: 11
Default PHP OOP question

Hi,
I am new to OOP and i am really confused about something in ZF program.
File -----Indexcontroller.php------

Code:
public $myNamespace;
    public function websession()
    {
        $this->myNamespace = new Zend_Session_Namespace('Default');
        if(isset($this->myNamespace->countPages))
        {
            $this->myNamespace->countPages++;
            
        }
        else
        {
            $this->myNamespace->countPages=1;
            
        }
        
        return $this->myNamespace->countPages;
    }


    public function indexAction()
    {
/*$this->view->title = "Our Albums";
$this->view->headTitle($this->view->title, 'PREPEND');
$albums = new Model_DbTable_Albums();
$this->view->albums = $albums->fetchAll();*/
$this->view->message=$this->websession();
    }

File-----index.phtml------
Code:
<h1>Message: <?php echo $this->message; ?></h1>

Above code display the refresh button pressed for a session. It is working fine. However, I have a few question regarding OOP.

File -----Indexcontroller.php------

1. I have tried
$this->view->message=$this->myNamespace->countPages;
but it looks like message variable is not storing it. It is not dipslaying it on webpage.

2. Why are we using $this->view->message instead of just $this->message? What is view?

File-----index.phtml------

3. <h1>Message: <?php echo $this->message; ?>
Why are we not using $this->view->message ?
We have stored the output of session in $this->view->message on indexController page but we are using only $this->message on index.phtml.

4.what is $this->escape($this->message); escape function in zend framework?

Please don't mind if i have asked stupid questions. I am new to OOP and ZF.
Thank You,
Umair
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-18-2009, 05:41 AM
Senior Member
 
Join Date: Jul 2008
Posts: 288
Default

2. $this->view in the controller is a Zend_View object, so setting
[php]$this->view->message = "foo";[/php] is setting the value "foo" to the variable "message" on the view object. Whereas, $this->message would be the message variable of the controller object.

3. This is in a view script (.phtml). This file is part of a Zend_View object (the same Zend_View object as in #2). So $this->message is the message variable of the view object (which was set from the controller).

4. $this->escape() is a function of the view that escapes the data for html output. It's basically a wrapper around htmlentities.
__________________
Brenton Alker
PHP Developer - Brisbane, Australia

blog.tekerson.com | twitter.com/tekerson | brenton.mp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT. The time now is 08:59 AM.


Designed by: Miner Skinz Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0