0

Possible Duplicate:
Assigning the return value of new by reference is deprecated

I'm trying to correct some mistakes that are displayed in my website, but I can not get rid of them.

For the following code:

    $string = preg_replace('# +#', ' ', $string);
    if($useHtml2text){
        $string=new html2text($string);
        $string=$string->get_text();
    }
    return trim($string);
}

I have this mistake

Deprecated: Assigning the return value of new by reference is deprecated in /htdocs/modules/googleshopping/class/myTools.php on line 56

the line concerned is this one

$string=new html2text($string);

I've tried almost everything but it is still there.

Community
  • 1
  • 1
Stanislas Piotrowski
  • 2,595
  • 10
  • 40
  • 59

1 Answers1

1

The errant code isn't in your script, but in /htdocs/modules/googleshopping/class/myTools.php on line 56.

A bit of time in Google suggests that this is a Prestashop module of some sort? Take it up with the module author. Tell them to get their act in gear, new-by-ref has been bad practice since PHP 5.0. Considering that the top Google result is also complaining about deprecated errors (about ereg -- ewwwww), I wish you luck. You might want to find an alternate module...

In the mean time, if you're seeing this on a production site, you'll want to turn off deprecated notices by adjusting error_reporting wherever most appropriate for your code, either in your init / bootstrap file or in php.ini.

Charles
  • 50,943
  • 13
  • 104
  • 142
  • thanks a lot, I actually bought this module to a french guy that do "no support". Actualy I have many trouble with that module In fact he told me that this module is compatible with pretashop 1.5 but I have too many mistakes. I'm trying to get rid of them step by step. thank you for the advices I appreciate that – Stanislas Piotrowski Jan 07 '13 at 09:42
  • If you paid for that code, get your money back as the author is blatantly incompetent. – Charles Jan 07 '13 at 09:43
  • I've paid 79 € for that. he do not want, I've signaled to the moderator but actualy I have no responses. I almost get rid of all errors. I have a last one. – Stanislas Piotrowski Jan 07 '13 at 09:47
  • 1
    Beware! Deprecated warnings often turn into fatal errors in subsequent releases! – gd1 Jan 07 '13 at 09:48
  • that is what I get, actually I removed all deprecated but I have that when I try to generated the xml for export on the line 420 `$product_link = $link->getProductLink((int)($product['details']->id), $product['details']->link_rewrite, $cat_link_rew, $product['details']->ean13, $lang['id_lang']);` This mistakes goes on Fatal error: Call to a member function getProductLink() on a non-object in /htdocs/modules/googleshopping/googleshopping.php on line 420 I'm trying to see what can be the cause of that mistake – Stanislas Piotrowski Jan 07 '13 at 09:51
  • Did you "get rid" of the deprecated error by, say, removing the line of code that was throwing it? The line of code causing the error is the creation of a new object. If that object later becomes the `$link` defined (or, rather, *not* defined) in the error you've just given here, that explains that. – Charles Jan 07 '13 at 09:52
  • in fact there was that caracter "&" so I removed them all where it was suggested then I have no mistakes like that, just this fatal error at the end – Stanislas Piotrowski Jan 07 '13 at 09:54
  • Okay. You'll want to consider a new question for that issue. If you can't track it down on your own, and do decide to post a new question, you'll want to be sure to include the entire function body inside of the question, which will be needed. – Charles Jan 07 '13 at 09:55
  • thanks a lot for your help. Really appreciated your patience – Stanislas Piotrowski Jan 07 '13 at 09:56