Because it was written during lunch break, I am not very careful about it.
The main issue is the old-fashioned issue of OOP...
I have been working for two years and have some ideas about oop, But I 've rummaged through the introduction of OOP in major bookstores (like writing it by myself)
<?PHPClassCar {PublicGetname (){Return $ This->Name ;}PublicGetspeed (){Return $ This->Speed ;}}?>
This kind of thing is believed to only appear in the book.Code.. (Except for JavaBean)
Based on these ideas, I have the following code:
<? PHP Class Order { Private _ Goodsarr = Array (); Public Function _ Construct (){} /* * @ Return goods {} */ Public Function Getgoods (){ // Search for the product number goods_sn under the order Foreach ( $ Goods_sn As $ Goods_sn ) Array_push ( $ This -> _ Goodsarr, New Goods ( $ Goods_sn )); Return $ This ->_ Goodsarr ;}} Class Goods { Public Function Getname (){}} $ Order1 = New Order ('anba01' ); $ Goodsarr = $ Order1 -> Getgoods (); Foreach ( $ Goodsarr As $ Goods ){ Echo $ Goods -> Getname (). '<br>' ;} ?>
But this is contrary to the Code in project development.
php class order { Public function __ construct () {} Public function getgoodsinfo ( Array ('name', 'price' )) { /// organize data structures } $ order2 = New Order ('aanba02' ); echo $ order2 -> getgoodsinfo ( array ('price' ); ?>
I personally think the first one is more in line with the object-oriented norms. But in actual development, it is often the second type.
Because it is not developed by one person, it can only be followed by mostProgramPersonnel. However, the reusability of such code is greatly reduced.
I have written the same function several times and wonder if you have supported my opinion. Welcome to shoot bricks ~