How the methods in the PHP class access other methods in the same way

Source: Internet
Author: User
How do the methods in the PHP class access other methods in the same way?
Class Action {

function A () {
Function B () {

}
}

Function C () {
How does this call the B method in the A method???
}

}

------Solution--------------------
Do not write like this, what bothered problem, must be so toss it? Say it, and we'll help you figure out a way. Don't try to chase this niu Jiao Jian
------Solution--------------------
It's no big deal.
PHP code
class Action {function A () {function B () {Echo    123;    }} function C () {//This is how to call the B method in the A method???  b (); }} $p = new Action; $p->a (); $p->c ();//123b ()//123 
------Solution--------------------
Hey, you can make mistakes sometimes.

You want the C function to use the B function, so you have to initialize a () before you use it.
Because a () inside PHP is gray to PHP does not know that a () has a B ()
So you do not initialize a () with B () will definitely go wrong. The
correct call is first A () in C ().
------Solution--------------------
PHP is a major feature, but also a tragedy is that the function definition has no scope, where all the line, as long as it appears.
------Solution--------------------
PHP code
class actio        n {function A () {$this->b ();        }//Pull out the B () function. function B () {} function C () {//) How do I call the B method in the A method???    $this->b (); }} 
  • 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.