You are here: Creating a class and reusing variables... « PHP SQL « IT news, forums, messages
Creating a class and reusing variables...

Posted by Bonge Boo! on 05/26/05 02:22

I hope this is an obvious question, but I'm very new to classes.

I have created a class that have a number of variables defined for it.

class cart {

var $username = "blah";
var $password = "blahblah";
var $database = "zippy";
var $hostname = "127.0.0.1";

Etc...

It suddenly struck me that it would make more sense to have these variables
stored in another php include so that other functions and scripts can use
these values without them being duplciated.

However I cannot find out how to pull my "global" variables into my class.

I believe I could make the values constants with

Define('USERNAME' , 'blah');

And simply use that a constant my class. But that also means going through a
whole load of code and changing my $username to USERNAME and probably
buggering something up there.

So if anyone can point the way to getting variables into a class from
"outside" I would appreciate it.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация