Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>in the function ,</p> <p>he dont know what is <code>$connection</code> variable,</p> <p>one option to send the connection as argument to the function</p> <pre><code>function get_all_subjects($connection) { .......... </code></pre> <p>}</p> <p>and call to function</p> <pre><code>$subject_set = get_all_subjects($connection); </code></pre> <p>look on variables scope <a href="http://php.net/manual/en/language.variables.scope.php" rel="nofollow">manual</a></p> <blockquote> <p>Here the <code>$a</code> variable will be available within the included b.inc script. However, within user-defined functions a local function scope is introduced. Any variable used inside a function is by default limited to the local function scope. For example:</p> </blockquote> <pre><code>&lt;?php $a = 1; /* global scope */ function test() { echo $a; /* reference to local scope variable */ } test(); ?&gt; </code></pre> <blockquote> <p>This script will not produce any output because the echo statement refers to a local version of the $a variable, and it has not been assigned a value within this scope. You may notice that this is a little bit different from the C language in that global variables in C are automatically available to functions unless specifically overridden by a local definition. This can cause some problems in that people may inadvertently change a global variable. In PHP global variables must be declared global inside a function if they are going to be used in that function.</p> </blockquote>
 

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