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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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