View Issue Details

IDProjectCategoryView StatusLast Update
0000515mantisbtfeaturepublic2003-12-13 04:48
ReporterrepAssigned Tojlatour  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionwon't fix 
Product Versionnone 
Summary0000515: Use of $g_***** for globals.
Description

Have you considered using some form of $GLOBAL[] array instead of all of the $g_**** variables? I have seen several scripts do this. It seems to make accessing the globals easier sinces all you have to do is tell the function about $GLOBAL[] instead of each of the variables individually.

TagsNo tags attached.

Activities

prescience

prescience

2001-05-23 22:08

reporter   ~0000774

Mmm, the thought has crossed my mind. I believe there would be some resource/performance issues since the number of globals is pretty large. At least that was what I gathered from some discussion on the topic on phpbuilder.net. Plus the number of globals used is pretty small for most functions.

One other thought was to put most everything into the database but that would potentially have serious performance problems.

Eesh, I wish I knew exactly how php/databases would behave so I could know for certain the tradeoffs without having to have an entirely different branch to test on. BTW: were any of these scripts of any significant size?

rep

rep

2001-05-23 23:47

reporter   ~0000777

PHP Nuke uses that idiom in at least one place (the first file I opened)


function FriendSend($sid) {
global $mpnTables,$phpEx;
if(!isset($sid)) { exit(); }
include ("header.$phpEx");
$result=mysql_query("select title from ".$mpnTables['stories']." where sid=$sid");


Note that they have a array of all of the table names that they use in all functions that do queries. That way user's can easily change table names around in MySQL (since some hosting services only allow one database per account). I would have guessed the performance advantage would have gone the other way but I trust those who have timed it more than my gut ;->

My gut REALLY tells me that sticking it in the database will NOT be faster!

Will check phpbuilder...

jlatour

jlatour

2003-02-16 06:32

reporter   ~0003706

This is no longer an issue with the introduction of config_api.php in 0.18.0