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:
  #1  
Old April 6th, 2004, 01:14 PM
glanneus glanneus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 glanneus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Global variables and classes

Hi!
I have a php script that uses classes and functions. The problem is that I need my sub functions to use and reach the same variabl myvar. But as it is now, it doesn't work. The functions are actually build in XML functions so I can't parse any variables to these functions. I am used to PHP but have little experience of classes in PHP. This script is part of AMFPHP the alternative to Flash Remoting so the following structure need to be the same. How can I solve this?
This simple example shows ruffly what I want to do:

PHP Code:
 myClass {
 function 
myFunction1() {
  function 
mySubfunction1() {
   global 
myvar;
  }
  function 
mySubfunction2() {
   global 
myvar;
   return 
myvar;
  }
  echo 
myvar;
 }



Thanks in advance!

Ellen

Reply With Quote
  #2  
Old April 6th, 2004, 03:50 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I don't see the point of using a vaguely OO structure if you're not taking advantage of the benefits of OOP. I believe you can have nesting functions in python, but to my knowledge, this is not possible in PHP. If you're using globals in OOP, you're doing something wrong.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old April 7th, 2004, 10:05 AM
glanneus glanneus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 glanneus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi again!

I am using classes because it is part of AMF PHP www.amfphp.org where the following structure is needed.

Cheers,
glanneus

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Global variables and classes


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT