hi there, this is my class that uses preg_replace_callback
I know that when this function used in class
i do like that
**preg_replace_callback('|(\d{2}/\d{2}/)(\d{4})|',array(&$this, 'next_year'), $text); **
but i dont understand & in front of $this statement
if i dont write the & reference operator in front of this it also works. what does it mean?
can anyone help to understand? thanks in advance
class az {
// the callback function
function __construct($text){
$this->ParseText($text);
}
function next_year($matches)
{
// as usual: $matches[0] is the complete match
// $matches[1] the match for the first subpattern
// enclosed in '(...)' and so on
return $matches[1].($matches[2]+1);
}
function ParseText($text)
{
return preg_replace_callback('|(\d{2}/\d{2}/)(\d{4})|',array(&$this, 'next_year'), $text);
}
}
class mm {
function yaz($text){
$n=new az($text);
}
}
$text = "April fools day is 04/01/2002\n";
$text.= "Last christmas was 12/24/2001\n";
$azs=new mm($text);