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=Ernesto wrote on Sun, 24 April 2011 11:50]You need to define it as global in your function since it is included. IE <SPAN name="php"><code><span style="color: #000000"> <span style="color: #0000BB"><?php[/notag]<span style="color: #007700">include([/notag]<span style="color: #DD0000">'globals.php'[/notag]<span style="color: #007700">);function Function() {global [/notag]<span style="color: #0000BB">$global[/notag]<span style="color: #007700">, [/notag]<span style="color: #0000BB">$global2[/notag]<span style="color: #007700">, [/notag]<span style="color: #0000BB">$etc[/notag]<span style="color: #007700">;echo [/notag]<span style="color: #0000BB">$global[/notag]<span style="color: #007700">;}[/notag]<span style="color: #0000BB">?>[/notag] [/notag] </code></SPAN> [/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 26 23:19:06 EDT 2025
Total time taken to generate the page: 0.03566 seconds