Current location: Hot Scripts Forums » Programming Languages » PHP » Global variable declaration


Global variable declaration

Reply
  #1 (permalink)  
Old 02-24-06, 04:59 AM
lcwei81 lcwei81 is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Global variable declaration

Hi all,
Here have a question would likes to ask those whom expericed the OOP structure in php.
If I have a global variable which name
global $sConn;(where $sConn is a object)
How I going to declare this in a class? Because currently, each time I need to connect with this object, I need to declare global $sConn in each function within a class.
Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-24-06, 05:22 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,167
Thanks: 3
Thanked 8 Times in 8 Posts
Hmm.... your question is a bit confusing. Here is an example:


PHP Code:

<?
class foo
{
       var 
cConn;
 
       function 
function1
       
{
             
// Some thing here
             
this->cConn "Bla ....";
       }
 
       function 
function2
       
{
             
// Some thing here
             
this->cConn "Something ....";
       }
       
// ....
 
}
In other words you can use the "cConn" variables using "this->cConn". Is that what you are asking?
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
using variable variables with multiple variables for parts of the name harlock PHP 7 07-26-05 08:35 PM
Redirection back to a page from form submit DAL Perl 11 03-21-05 03:45 PM
HELP... Global declaration. jozin PHP 1 11-23-04 05:06 AM
PHP Error Fairnie PHP 8 06-26-04 08:15 AM
variable declaration gmadhukarreddy Perl 1 01-16-04 03:01 PM


All times are GMT -5. The time now is 01:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.