On 2 Oct 2002 at 22:06, Anna Gyor wrote: > how can I use global variables in my web portal? I have read the php > documentation, but it works only in the same file. I want use more > global variable on many php site. > > For example: > In login.php I use the code > > $first=mysql_result($result,0,"FIRST_NAME"); > > and I want to print this $first variable all of my php site.
Easy, use one script for your whole site. There is nothing that drives me more nuts than to encounter an application whose developers have left town and run into global variables. I don't mind file scoped variables so much, but to make a variable global across an application can drive one nuts when trying to debug. That said, I do use global variables but they are from a class whose 'object' is global. I don't have 3000 php files running all over my site as I've seen done. I have just a couple of *handlers* that use classes and I have one class which creates my global array which is shared. It's very easy to trace variables. I'd be very careful before I began to make variables global without some EASYmeans of tracing them. And it gets real interesting when one file inherits another which inherits another and in any one of them the value of your global variable can be changed. Does anyone know a good way for tracing such things? Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php