Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>unless I miss my guess when you initiate a value in:</p> <pre><code>public function init(){ $this-&gt;value = 'value'; } </code></pre> <p>the value is available to all of the 'actions' in the controller.</p> <p>This is by design.</p> <p>The <code>init()</code> method is used in ZF1 to supplement the constructor. It's where you add arguments that might normally be put in the constructor.</p> <p>In order to <em>persist</em> a value from one action to another, some form of storage must be used.</p> <p>For example:</p> <pre><code>//a verbose example public function indexAction(){ //initiate a variable $i = 100; //start a new session and assign a name to it $session = new Zend_Session_Namespace('number'); //assign the value to the namespace $session-&gt;value = $i } </code></pre> <p>later in that same controller or even another controller</p> <pre><code>public function newAction(){ //access the session $session = new Zend_Session_Namespace('number'); //assign the value to the view $this-&gt;view-&gt;value = $session-&gt;value; } </code></pre> <p>now in the new.phtml view</p> <pre><code>&lt;?php echo $this-value ?&gt; </code></pre> <p>An important thing to remember when using PHP and specifically Zend Framework 1, every request runs the entire application. </p> <p>This was a concept that tripped me up in the beginning. Every time you request a new page your Zend Framework application runs from scratch, so any data that needs to survive from one request to the next must be saved (persisted).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload