I'm confused.

Source: Internet
Author: User
I think it's confusing. PHPcode & lt ;? PhpclasscA {/*** testpropertyforusingdirectdefavalue value */protectedstatic $ ite I am confused
PHP code
  
   * Foo * cB * Tango * cC * Foo * cD *  * What the hell?! :) */?>



Is this overwriting, or what? Why is the output so incomprehensible? it sounds messy.

------ Solution --------------------
What is this? Looking for trouble!
Tired
------ Solution --------------------
It doesn't matter if you don't understand it.
------ Solution --------------------
Discussion

What is this? Make dumplings for trouble!
Tired

------ Solution --------------------
This may make it clearer.
PHP code
Class cA {/*** Test property for using direct default value * use the direct default value to Test the property */protected static $ item = 'foo '; /*** Test property for using indirect default value * use indirect default value to Test the property */protected static $ other = 'CA'; public static function method () {print _ METHOD __. ''. _ CLASS __. ': $ item = '. self: $ item. "\ r \ n"; print _ METHOD __. ''. _ CLASS __. ': $ otfer = '. self: $ other. "\ r \ n";} public stat Ic function setOther ($ val) {self: $ other = $ val; // Set a value in this scope .}} class cB extends cA {/*** Test property with redefined default value * Redefining the default Test property */protected static $ item = 'bar '; public static function setOther ($ val) {self: $ other = $ val ;}} class cC extends cA {/*** Test property with redefined default value * Redefining the default Test property */protected static $ item = 'tnang'; public static Function method () {print _ METHOD __. ''. _ CLASS __. ': $ item = '. self: $ item. "\ r \ n"; print _ METHOD __. ''. _ CLASS __. ': $ otfer = '. self: $ other. "\ r \ n";}/*** Now we drop redeclaring the setOther () method, use cA with 'self: 'Just for fun. */} class cD extends cA {/*** Test property with redefined default value * Redefining the default Test property */protected static $ item = 'Foxtrot '; /*** Now we drop re Declaring all methods to complete this issue. * Now, let's discard all the methods that are re-declared to solve this problem */} cB: setOther ('cb '); // It's cB: method ()! CB: method (); // It's cA: method ()! CC: setOther ('CC'); // It's cA: method ()! CC: method (); // It's cC: method ()! CD: setOther ('CD'); // It's cA: method ()! CD: method (); // It's cA: method ()!

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.