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 8019819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:30:29+00:00 2026-06-04T21:30:29+00:00

I am have a problem with undestanding some sentence at PHP.net about the static

  • 0

I am have a problem with undestanding some sentence at PHP.net about the static keyword,
At This Link, PHP.net Explaining about the static keyword i did understand all they say but i didn’t succeed to get one sentence witch start at “Like any other PHP static variable”.
I just didn’t get it if can some one please help me with code example, mabye explanation will be great.

  • 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-04T21:30:31+00:00Added an answer on June 4, 2026 at 9:30 pm

    When saying “like any other static variable” the manual refers to a static variable inside a function. The archetypal example is the function that keeps an internal counter:

    function foo() {
        static $counter = 0; // static variable
        return ++$counter;
    }
    

    Static variables like this and static class properties both have a limitation on the expressions you can initialize them with.

    function foo() {
        static $counter = getInitialValue(); // ERROR: not possible!
        return ++$counter;
    }
    

    If you need to do something like this, the usual workaround is

    function foo() {
        static $counter; // not initialized explicitly, same as = null
        if ($counter === null) { // three equals!
            $counter = getInitialValue();
        }
        return ++$counter;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem in understanding how does the asp.net mvc deal with Null
I have a little problem understanding XMLHttpRequest 's handlers. The specification says this about
i'm starting to work with php basics and i have some problem understanding how
hello everyone I have some problem with understanding this piece of the code: import
I have a problem with understanding of some basic OOP concepts. I'll try to
I have some small problem in understanding Value Objects in Flex... I'm trying to
I have a problem in understanding OOP... This is it : Sometime's you create
I'm coding some web-applications in MVC, and I have a problem with something that
the biggest problem I have is understanding why some of my code wont work
I think I have some basic understanding problem so maybe someone's able to help

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.