SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old January 25th, 2003, 07:07 PM
wAr-AnGeL wAr-AnGeL is offline
Forum Security
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Behind You
Posts: 479 wAr-AnGeL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m
Reputation Power: 7
Send a message via ICQ to wAr-AnGeL Send a message via AIM to wAr-AnGeL
Question Global Variables

Been working on a small script and have ran into a small problem. How do I make variables global to all functions inside a class? I tried global $somevar but that didn't seem to work. Any help would be appreciated. Thanks
__________________




"Only Linux users see the end of crashes."
- Pl4t0

Reply With Quote
  #2  
Old January 26th, 2003, 09:27 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
war.. the only thing I could find is that you could declare the globals before starting the class.. then using them within the class...

this page shows a small example of that.. other than that I'm not too sure... sorry.. I'm still learning about classes :P hope this helps

http://www.webkreator.com/php/techn...-variables.html

Reply With Quote
  #3  
Old January 26th, 2003, 10:06 AM
Vasarab69 Vasarab69 is offline
Goldmember
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 71 Vasarab69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 25 sec
Reputation Power: 6
Send a message via AIM to Vasarab69
classes are still a fairly new concept to me, however, i think it goes like...

PHP Code:
class SomeClass {
    var 
$somevar;
    var 
$someothervar;
    
// ETC., above is where the global vars go

    
function SomeClass () {
          
// constructor, which is run with every class execution
          // etc.,
    
}
// rest of script goes here

__________________
-Alexander

Reply With Quote
  #4  
Old January 26th, 2003, 07:30 PM
limnil limnil is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Lithuania
Posts: 20 limnil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How do I make variables global to all functions inside a class:
$a_help="me";
$a_me="help";

class how_do{
var $a_help;
var $a_me;


function how_do() {
global $b_help, $b_me;


$this->a_help = $b_help;
$this->b_me = $b_me;
}

}

i hope it will help u

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Global Variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway