CakePHP view variable scope issue -


i have these lines in view file

////////////////////////////  $a = 5; showme()  showme() {  global $a;  echo $a; }  //////////////////////////////// 

problem: $a not accessible in showme() function.

i have no choice pass $a argument , no choice move function view. , should accessible in function through global keyword only.

i can change way of declaration $a.

you missing semi-colon end later statement:

$a = 5; showme() 

change to:

$a = 5; showme(); 

your code seems ok, should work, not sure may try if inside class:

$a = 5; $this->showme(); 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -