Forum Search:
FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.
Calendar
Search
Help
Members
Control Panel
Logout [ CommonCrawl [Bot] ]
Home
Post Form
Logged in user:
CommonCrawl [Bot] [
logout
]
Forum:
Bug Reports
Title:
Poll:
[CREATE POLL]
Message Icon:
No Icon
Smiley Shortcuts:
[
list all smilies
]
Formatting Tools:
Size
1
2
3
4
5
6
7
Color
Sky Blue
Royal Blue
Blue
Dark Blue
Orange
Orange Red
Crimson
Red
Firebrick
Dark Red
Green
Lime Green
Sea Green
Deep Pink
Tomato
Coral
Purple
Indigo
Burly Wood
Sandy Brown
Sienna
Chocolate
Teal
Silver
Font
Arial
Times
Courier
Century
Body:
Forum Options:
HTML
code is
off
BBcode
is
on
Images
are
on
Smilies
are
on
Editing Time Limit
: Unlimited
[quote title=Dayo wrote on Mon, 25 April 2011 03:13]You missed the main point being made ... [quote title=Quote:]...When I include GLOBALS.php from within a function in an external application, Variable $XYZ is no longer global in scope but is now local to my function.[/quote] The key terms are "function" and "external application". Function autoCalledBySomeEventInExternalApplication() { // Log user into FUDforum code from [url]http://cvs.prohost.org/index.php/Login_integration#Example[/url] //Try to get user details to feed to external application require_once 'scripts/fudapi.inc.php'; Call a function in fudapi.inc.php //Fails because many functions fudapi.inc.php use $GLOBALS['XYZ'] which will always be empty in this case. }[/quote]
File Attachments:
Allowed File Extensions:
jpg jpeg png gif txt doc gz bz2 inc php zip diff
Maximum File Size:
1024KB
Maximum Files Per Message:
5
Options:
Post Notification
Notify me when someone replies to this message.
Include Signature
Include your profile signature.
Disable smilies in this message
Topic View
Post by Dayo is ignored
Re: GLOBALS.php "Bug"??
Thu, 28 April 2011 09:20
Ernesto
Karma:
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.
Post by Dayo is ignored
Re: GLOBALS.php "Bug"??
Wed, 27 April 2011 08:55
Ernesto
Karma:
I see, and referencing the variables as globals within the function as I suggested does not work?
Post by Dayo is ignored
Re: GLOBALS.php "Bug"??
Sun, 24 April 2011 11:50
Ernesto
Karma:
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
;
}
?>
Post by Dayo is ignored
Current Time:
Sat Apr 19 03:42:45 EDT 2025
Total time taken to generate the page: 0.04167 seconds