To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Upgrading PHP

Upgrading PHP Issues concerning PHP version upgrades and future releases

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-28-2004, 01:48 AM   #1
doorman
Junior Member
 
Join Date: Sep 2004
Location: Sydney, AUS
Posts: 5
static variables in static functions

How do you access static variables from statically called functions.
IE how do i fill in the dots.

class myClass{
static $sv = 1;

function myFunc(){
printf( "sv = %s<BR>", .......sv );
}
}

myClass::myFunc();
myClass::myFunc();

I know that $this is not accepted in static functions and myClass::sv doesn't work either. Is it possible at all? have
I misunderstood some oo principal? any advice would be welcome.
doorman is offline   Reply With Quote
Old 09-28-2004, 05:34 AM   #2
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,124
myClass::$variable works for me
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Old 09-28-2004, 09:53 AM   #3
Shrike
Not Yet Involved
 
Shrike's Avatar
 
Join Date: Oct 2003
Location: The Eighth, Sursamen
Posts: 2,254
PHP Code:
class myClass{
  static
$sv = 1;
  function
myFunc(){
    
printf( "sv = %s<BR>", self::$sv );
  }
}
myClass::myFunc();
__________________
The Hundredth Idiot
Shrike is offline   Reply With Quote
Old 09-29-2004, 03:50 AM   #4
doorman
Junior Member
 
Join Date: Sep 2004
Location: Sydney, AUS
Posts: 5
Thanks guys, I guess I just missed the $ in myClass::$sv
doorman is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 05:56 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.