Php policy mode problems ~ Bottom ~ Thank you for helping me change the following code.

Source: Internet
Author: User
Php policy mode problems ~~~ Expert guidance ~~ Thank you for helping me change the code below. I made the interface for learning martial arts and using weapons, and made the behavior into a class. but how to use it is messy. Subscribe to PHPcode & lt ;? Phpjavasactclassperson {question about the abstractpublicfunctionspeak php policy mode ~~~ Expert guidance ~~ Thank you for helping me change the following code.
I made martial arts and weapons into an interface and behavior into a class, but how to use them is messy. Score immediately

PHP code
  
  Studywx (studtq); $ chperson-> usewq (xiaoqiang); $ chperson-> studywx (studtq); $ amperson = new amperson (); $ amperson-> studywx (studyw ); $ amperson-> usewq (xiaoqiang); $ amperson-> studywx (qiang);?>


------ Solution --------------------
It simplifies your example a little. it should be much clearer to see the annotations.
PHP code
  Studywx ();} public function usewq ($ wq) {$ wq-> usewq () ;}} class chperson extends person {public function speak () {echo "Chinese are talking, different routes! ~ ";}} Class amperson extends person {public function speak () {echo" the Americans are talking about it !~ ";}} Interface istudy {public function studywx ();} class studyw implements istudy {public function studywx () {echo" ";}} class studtq implements istudy {public function studywx () {echo "sunflower collection" ;}} interface iwq {public function usewq ();} class jian implements iwq {public function usewq () {echo "" ;}} class qiang implements iwq {public function usewq () {echo "foreign gun" ;}}$ chiness = new chperson (); // add a Chinese guy $ chiness-> studywx (new studyw (); // learn $ chiness-> usewq (new jian ()); // give him the $ american = new amperson (); // bring up an american $ american-> studywx (new studtq ()); // $ american-> usewq (new qiang (); // give him a broken foreign gun

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.