Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:24:34+00:00 2026-06-14T04:24:34+00:00

Is it possible to make a function that unsets a variable when it is

  • 0

Is it possible to make a function that unsets a variable when it is used X time(s)?

I’m aware of unset() and how it works.
This would be handy for the security sake.

For example to automaticlly unset personal information that I obtained from a MySQL database, having 1000-2000 unset() in the code just looks so messy!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:24:35+00:00Added an answer on June 14, 2026 at 4:24 am

    Although your question doesn’t make perfectly sense here’s a possibility to do it:

    class ExpiredValue {
        private $data;
        private $access_counter;
        private $max_access;
    
        public function __construct($data, $max_access) {
            $this->max_access = $max_access;
            $this->__invoke($data);
        }
    
        public function __invoke($data = null) {
            if(func_num_args() == 0) {
                $this->access_counter++;
                if($this->access_counter > $this->max_access) {
                    $this->data = null; // remove data from memory
                }
                return $this->data;
            } else if(func_num_args() == 1) {
                $this->access_counter = 0;
                $this->data = $data;
            }
        }
    }
    

    How to use:

    $value = new ExpiredValue("<data>", 3);
    echo $value(); // "<data>"
    $value("<other data>");
    echo $value(); // "<other data>"
    echo $value(); // "<other data>"
    echo $value(); // "<other data>"
    echo $value(); // null
    

    Mostly if you begin to think about stuff like this you’re on the wrong way. It sometimes helps to take a step back and figure out what the real problem is. Your problem is not really that there is not a good possibility to expire your variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(#tab1).click(function(){ loadTab(1); $('div.HOMEtabdiv ul.HOMEtabs a').removeClass('selected'); $(this).addClass('selected'); }); Would it be possible to make the
I would like to make a function that will create objects that have a
function ajaxFunction(phpFunction){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera
is it possible to make a function that takes form data and executes a
std::find_if takes a predicate in one of it's overloaded function. Binders make it possible
Is it possible make some handler that will do something when user shutdown computer
Is it possible make an activity, that will lock the android device? That device
Possible Duplicate: Make error: missing separator I am so stressed out by this silly
So I have to make a function that finds a pair with its 1st
I want to make a function that takes a list eg [('A',3), ('B',2), ('C',2),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.