Re: Functions does not find global in views?!!

2010-06-29 Thread Jeremy Burns | Class Outfit
Why are you creating the variable again, and why is it global?

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 29 Jun 2010, at 00:13, saidbakr wrote:

 Hi,
 I set to a view variable called $tests and it is array of some data.
 In the view, print_r($tests) prints out the array construction
 correctly and without any problems.
 
 In the regarded view, I created a function to perform a simple task on
 the values of $tests. However, when I try to define the variable
 $tests as global in the function, it seems that the function could not
 able to catch this variable.
 print_r($tests);
 function foo(){
 global $tests;
 // do some logic  code
 }
 
 I don't know why I got this strange result in the view file?!
 
 Check out the new CakePHP Questions site http://cakeqs.org and help others 
 with their CakePHP related questions.
 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Functions does not find global in views?!!

2010-06-29 Thread saidbakr
Because I don't want to use it as a parameter of the function. I just
want the function to deal with it as any variable set from the
controller.

On Jun 29, 9:04 am, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 Why are you creating the variable again, and why is it global?

 Jeremy Burns
 Class Outfit

 jeremybu...@classoutfit.comhttp://www.classoutfit.com

 On 29 Jun 2010, at 00:13, saidbakr wrote:

  Hi,
  I set to a view variable called $tests and it is array of some data.
  In the view, print_r($tests) prints out the array construction
  correctly and without any problems.

  In the regarded view, I created a function to perform a simple task on
  the values of $tests. However, when I try to define the variable
  $tests as global in the function, it seems that the function could not
  able to catch this variable.
  print_r($tests);
  function foo(){
  global $tests;
  // do some logic  code
  }

  I don't know why I got this strange result in the view file?!

  Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
  with their CakePHP related questions.

  You received this message because you are subscribed to the Google Groups 
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group 
  athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Functions does not find global in views?!!

2010-06-28 Thread saidbakr
Hi,
I set to a view variable called $tests and it is array of some data.
In the view, print_r($tests) prints out the array construction
correctly and without any problems.

In the regarded view, I created a function to perform a simple task on
the values of $tests. However, when I try to define the variable
$tests as global in the function, it seems that the function could not
able to catch this variable.
print_r($tests);
function foo(){
global $tests;
// do some logic  code
}

I don't know why I got this strange result in the view file?!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en