FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » GLOBALS.php "Bug"??
Show: Today's Messages :: Unread Messages :: Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Message by Dayo is ignored  [reveal message]  [reveal all messages by Dayo]  [stop ignoring this user] Go to next message
Re: GLOBALS.php "Bug"?? [message #165098 is a reply to message #165087] Sun, 24 April 2011 11:50 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
remove from buddy list
ignore all messages by this user
You need to define it as global in your function since it is included.

IE
<?php
include('globals.php');

function Function() {
global 
$global$global2$etc;

echo 
$global;
}
?>




Message by Dayo is ignored  [reveal message]  [reveal all messages by Dayo]  [stop ignoring this user] Go to previous messageGo to next message
Re: GLOBALS.php "Bug"?? [message #165119 is a reply to message #165102] Wed, 27 April 2011 08:55 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
remove from buddy list
ignore all messages by this user
I see, and referencing the variables as globals within the function as I suggested does not work?

Re: GLOBALS.php "Bug"?? [message #165121 is a reply to message #165119] Wed, 27 April 2011 22:49 Go to previous messageGo to next message
Dayo is currently offline  Dayo   
Messages: 101
Registered: April 2011
Karma: 0
Senior Member
add to buddy list
stop ignoring messages by this user
I get what you mean now.

Should work in most instances but not a suitable way to go about things. I'll have to go through the code called by FUDforum, find every one of the variables and declare them one by one. This is hellish and should not be neccessary at all.

I can see that in some places the variables are referenced directly, $XYZ, and in some others, using GLOBALS['XYZ\].

Now this is fair enough within the application but a more disciplined and structured approach is needed as while this may mean more work at times, it will make the application more extensible.


Define the stuff in GLOBALS.php as constants (not variables, global or otherwise) at the beginning of the flow and that's that. We know they are not going to change so why a variable in the first place anyway?

From then on, "CONF_XYZ" for instance, can be referred to anywhere without fear of tripping over anything. You don't, as a third party developer, have to wonder wherether you need to use this form or that form in this place or that place or whether ypou need to do anything special or not.

Will make things clean, structured and extensible.

So not quite a bug as such but more of a weakness in the design structure ... one which affects many other things in the application in general and one which puts obstacles in the way of third party devs.

I came to FUDforum because a feature I wanted, mailing lists, was not available elsewhere but have now realised that it would have been easier for me to try write a plugin to do this for phpBB3 due to having to have to overcome these structural issues in the main application here.

I'll suggest that a step back is needed for the next bigger point release to look at these issues. Basically a more "OOP" based approach is needed I think.

Anyway, just my 2 pence as an outsider trying to get a bit deeper into things.
Re: GLOBALS.php "Bug"?? [message #165127 is a reply to message #165121] Thu, 28 April 2011 09:20 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
remove from buddy list
ignore all messages by this user
If you include something in a function, the result will be local unless specifically defined as global within the function.

So if you include the file outside the function, it will be global or "public" using .NET terminology.

If you want to be able to access a local variable outside the parent function you have to declare it global or supergloba, either by declaring it within the global scope, or defining it as global within the function.

If that makes sense?

From the bottom of my heart I do not mean any offense, but I think you are mistaking this as a structural issue whereas in you are just "doing it wrong" as the lolcat would have said. But, I have been wrong a million thousand billion times before and this could sure as hell be one of those times again.


Message by Dayo is ignored  [reveal message]  [reveal all messages by Dayo]  [stop ignoring this user] Go to previous message
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: SQL Error has occurred...
Next Topic: NNTP Import Subject with Non-Ascii Characters
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat May 24 09:22:09 EDT 2025

Total time taken to generate the page: 0.04032 seconds