Closed Takuaraa closed 7 years ago
Hello,
I'm having a problem. This is an example of my code:
$links = array(); $test = "OK"; $client = new Client(); $crawler = $client->request('GET', $url); echo $test; $links = $crawler->filter('a')->each(function ($node){ echo $test; });
The first echo $test works, the second one not. It seems that inside the filter.. $test is null. Why is that? How can I fix that?
Thank you.
Please see http://php.net/manual/en/functions.anonymous.php
You need
$links = $crawler->filter('a')->each(function ($node) use ($test) { echo $test; });
Hello,
I'm having a problem. This is an example of my code:
The first echo $test works, the second one not. It seems that inside the filter.. $test is null. Why is that? How can I fix that?
Thank you.