search
HomeBackend DevelopmentPHP ProblemHow to delete global variables in php

php method to delete global variables: 1. Open the corresponding PHP code file; 2. Find the global variable; 3. Delete the global variable through the "unset($db,$user);" method.

How to delete global variables in php

The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

How to delete global variables in php?

global Only declare references to global variables in functions

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

$Function destruction

global $db;
global $user;
unset($db,$user);

Related introduction:

Super global variables were introduced in PHP 4.1.0 and are built-in variables that are always available in all scopes.

PHP Global Variables - Superglobal Variables

Many of the predefined variables in PHP are "superglobal", which means they are available throughout the entire scope of a script. They can be accessed within a function or method without executing global $variable;.

These super global variables are:

$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to delete global variables in php. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.