Jump to content

Recommended Posts

You need a visibility operator in front of 'static', like 'public' or 'private'.  Also are you declaring that variable outside a class? As far as I know, static variables are restricted to classes, though I miay be wrong.

Check out [url=http://uk.php.net/manual/en/language.oop5.static.php]static keyword[/url] at PHP.net
Isn't that fatally recursive?

If you're just looking for a static class that you don't have to instantiate, declare the members of a standard class 'static' and then access them with the :: operator, like this (from the above linked page)...

[code]
class Foo
{
  public static $my_static = 'foo';
  .
  .
  .
}

print Foo::$my_static . "\n";
[/code]

Is that what you're after?
[quote author=Jenk link=topic=114130.msg464240#msg464240 date=1162908769]
it would have to be:
[code]<?php
class MyClass
{
  private static $my_instance;

  function getInstance()
  {
      self::$my_instance = new MyClass();
  }
}
?>[/code]
[/quote]

whoops my bad. cheers ;)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.