Is it OK to put the functions in PHP anywhere? No matter where you put it, it's not going to be executed directly.

Source: Internet
Author: User
Will the PHP statements that are not included in a function be executed sequentially? Is JS also like this? Not reading the textbook is Trouble Ah, so basic things have to ask. Before I heard that there are some major differences between the C language Foundation and I can use PHP directly, I really believe it.


Reply to discussion (solution)

Will the PHP statements that are not included in a function be executed sequentially? Is JS also like this?
That's theoretically true.

If you're talking about a custom function, usually placed in front of the calling statement, PHP executes in a sequential
Unless it is a magic method and function, the custom function does not execute automatically and requires a statement call

Yes, the functions in PHP can be anywhere, no matter where they are placed, they will not be executed directly.
The principle remains: Define first, then use
In the same file, you can define it first.

The PHP parser will read the entire PHP file before parsing the output, so it is possible to define it first.
However, in order to clean the specification, it is best to define and call first.

  • Related Article

    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.