Fri, 17 May 2024


How to unset a global variable inside of a PHP function?

By: Nathalie, NetArt Media
Tue, 10 August 2021

In order to do this the $GLOBALS array should be used, for example:

<?php

function MyFunction()
{
unset($GLOBALS["myVar"]);
}

$myVar="value";

MyFunction();

?>


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox