PHP What does function statement., variable not persistent

21 views Asked by At

I am trying to use some Goutte code :

$oldtext='';
// Get the latest post in this category and display the titles
$crawler->filter('h2 > a')->each(function ($node) {
    print $node->text()."\n";
    $oldtext=$node->text();
    print $oldtext."\n";
});

I have 2 questions :

  1. what does statement "function ($node)" it's kind of inline function definition
  2. why $oldtext variable it's not presistent ? it's like inside of "function ($node)" all variables are reinitiated
0

There are 0 answers