PHP 7 and WordPress: How to FIX unexpected ‘new’ (T_NEW) error

Hey,

after I’ve upgraded my PHP to version 7 I found the following error being displayed for one plugin I was using:

Plugin could not be activated because it triggered a fatal error.

Parse error: syntax error, unexpected ‘new’ (T_NEW) in /var/www/vhosts/wp-content/plugins/smilies-themer/smilies-themer.php on line 80

The solution was pretty easy. Just open an editor on the file and line PHP tells you. Now you should see something like

$this->smilies =& new smilies_package($this->current_smilies);

Here they made some changes in PHP 7. You can’t assign classes with a & symbol anymore. So just remove that & symbol and the plugin will work fine again (search for multiple occurences).

Here you go, have fun with very fast working new PHP 7 and your (old) WordPress !

Leave a comment ?

31 Comments.

  1. thanks. works for me (so far)

  2. Thanks that was a great help about removing the & from &new when using php 7.0.

    Regards: Graeme

  3. Thanks, i’m examining some old plugins and this really helped me!

  4. Thanks dude, to thepoint and correct!

  5. :twisted: Awesome, thanks for the easy fix.

  6. Great!! Thank you. I have fixed a WEBSVN issue using diff

  7. Thanks, it was helpfull.

  8. Sweet, exactly what I needed :D

  9. Thanks! Checked many sites and yours was the only solution that actually worked!!

  10. Thank you, it’s work

  11. Removing the ‘&’ in the php file worked.
    Thank you!

  12. Thanks for the & thing. Worked for me. (so far :cool: )

  13. thanks a ton. works like a charm. :D

  14. Thanks man. Works like a charm

  15. Thank you! This sorted a lot of problems for me. Excellent.

  16. THANK YOU FOR POSTING! This could have wasted hours. Much appreciated!

  17. visit these guys

    Oh my goodness! Incredible article dude! Thank you, However I am having problems with your RSS.
    I don’t know the reason why I am unable to subscribe to it.
    Is there anyone else having the same RSS issues? Anybody who knows the solution will you kindly respond?
    Thanx!!

  18. Thanks a lot! You just saved my life (and my wife’s Website). :)

  19. Thanks. For those wanting to search for files where this might be a problem, here is a decent grep: grep -rn -i –include \*.php ‘= &new’ .

  20. Thank you so much for this easy solution..

  21. Brilliant, helped me solve and fix a site search issue I was having. Thanks for this!

  22. Worked for me too – Thanks!

  23. Thanks! That fixed it.

  24. :*
    Thanks!!!! Big Help

  25. Thanks – perfect solution

  26. THANKS!!!

  27. Thank you! Thank you! Thank you!

  28. sheds for sale

    First off I want to say awesome blog! I had a quick question in which I’d like
    to ask if you do not mind. I was interested to know how you center yourself and clear your
    head prior to writing. I have had difficulty
    clearing my thoughts in getting my ideas out there. I do enjoy writing
    but it just seems like the first 10 to 15 minutes are
    generally wasted just trying to figure out how to begin. Any ideas or hints?
    Kudos!

Leave a Comment