7

I know that it's creating a reference in other cases. But what happens here?

$crawler = &new MyCrawler();
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ajsie
  • 77,632
  • 106
  • 276
  • 381

2 Answers2

7

It creates an instance of MyCrawler and passes the reference for that instance into $crawler. In PHP5 this is assumed so the use of the & is deprecated.

See Object References (the Ampersand).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Joel Etherton
  • 37,325
  • 10
  • 89
  • 104
6

That is deprecated per the PHP documentation

Dancrumb
  • 26,597
  • 10
  • 74
  • 130
  • More that you shouldn't... deprecated features will ultimately be removed, resulting in broken code. – Dancrumb Feb 19 '10 at 23:25
  • ...resulting in DATED code. it's technically not broken UNTIL you update your PHP version but don't bring your code up to date (which is what migration guides are for). The code is not broken if it works as intended in PHP version it was intended for. – hndcrftd Mar 11 '20 at 18:12