Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@A Smith, let me try to clarify what you mean.</p> <ol> <li>You have several variables, example : <code>$var1</code>, <code>$var2</code>, etc.</li> <li>You have two function (or more) and need to access that variables.</li> </ol> <p>If that what you mean, so this may will help you :</p> <pre><code>global $var1,$var2; function a($params){ global $var1; $var1 = 1; } function b($params){ global $var1,$var2; if($var1 == 1){ $var2 = 2; } } </code></pre> <p>Just remember to define <strong>global</strong> whenever you want to access global scope variable accross function. You may <a href="http://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.global" rel="nofollow">READ THIS</a> to make it clear.</p> <p><strong>EDITED</strong></p> <p>Now, its clear. Then you can do this :</p> <pre><code>class function_passing_variables{ // add these lines var $email = ""; var $name = ""; var $username = ""; // .... </code></pre> <p>Then in your <strong><code>function a($request)</code></strong> change this :</p> <pre><code>$email=$pparams['data_email']; $name=$pparams['data_name']; $username=$pparams['data_username']; </code></pre> <p>to :</p> <pre><code>$this-&gt;email=$pparams['data_email']; $this-&gt;name=$pparams['data_name']; $this-&gt;username=$pparams['data_username']; </code></pre> <p>Now, you can access it in your <strong><code>function b($request)</code></strong> by this :</p> <pre><code>echo $this-&gt;email; echo $this-&gt;name; echo $this-&gt;username; </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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