So .. I'm wondering what its effect is
$ value-> SetProduct ($ product); $ Product- & gt; SetPrice ($ value); Resonance $ product- & gt; Milpris () - & gt; GetTotal ();
It shows RECURSION if I type print_r ($ product)
You have set two objects in the context of each other. Consequently, when you try to print one of them, you end up with recursion Because the objects continually referenced each other.
For example, how your product object looks:
Products | Price | Products | Price | Products | Price
... and for this reason, because each product can access the context of value, which can access the context of the product and it is still going on.
The app can be better designed by setting the value reference in the product object. If you think about it in terms of your example rational, then the value does not need to know about the product. For example, the cost of a book is most likely to be that the methods which allow value to be set, value can be used, or can be taxed. Price object will not need to access anything from the product in any manner. Although once you have a product object, you have to know about the product as the price.
Comments
Post a Comment