How PHP unregisters global variables defined by global

Source: Internet
Author: User
Recent look at high-performance PHP, found that for global variables, after the use of the log off, to free memory.

Baidu later found Unregister_globals (); This function, but is not too sure.

Please the great God pointing twos ~ ~


Reply to discussion (solution)

Who is so bored that you do this weird thing?

Is this weird?

I understand it wrong. Just use unset () to drop the global variable!!

You're probably in the function of global, right? The function is automatically released when it runs out ... So you don't have to do anything.
I'm guessing you're messing with $global.

You're probably in the function of global, right? The function is automatically released when it runs out ... So you don't have to do anything.
I'm guessing you're messing with $global.



The code is like this
Global $db;
Global $user;

Unset ($db, $user);

If there is no unset, $db, $user will be automatically released at the end of the function?

Global is only used to declare a reference in a function
Please do not misuse outside the function to avoid unnecessary misunderstanding.

PHP will release all resources at the end of the program, including variables

Unset () It's okay.

Global is only used to declare a reference in a function
Please do not misuse outside the function to avoid unnecessary misunderstanding.

PHP will release all resources at the end of the program, including variables



Oh, thank you.
  • 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.