Monday, June 2, 2014

Re: 3.0 - Getting variables into anonymous functions

Oh, that's handy.  As you can see, I've zero experience in anonymous functions.

For those at home:

$name = 'CakePHP';
$query = $articles->find();
$query->matching('Tags', function($q) use ($name){      return $q->where(['Tags.name' => $name]);  });

On Tuesday, 3 June 2014 14:45:14 UTC+10, Dakota wrote:
Use the use statement. See http://www.php.net/manual/en/functions.anonymous.php example 3 for an example.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: