finebynature had a nasty error message being displayed yesterday..
Fatal error: Cannot re-assign $this in /home2/finebyn/public_html/classes/cart.php on line 28
That was it, all that was displayed on the site.
My first thought was - I really should have provided a nice fallback page for fatal errors
Looking back at the offending line of code - i’m surprised it Ever worked in Any version of PHP.
class Cart() { function Cart() { session_start(); if (empty($_SESSION[‘cart’])) { // init object and things.. $_SESSION[‘cart’] = $this; } $this = $_SESSION[‘cart’]; } }
From within the objects constructor I was re-setting The Object that holds that constructor.
I fixed the problem by re-setting the properties of the object from those in the session and not the Whole object itself.