Export local variable to global variable scope?
Export local variable to global variable scope?
am 29.09.2007 14:23:58 von howa
Hello,
I have a function, e.g.
function foo() {
include("bar.php");
}
and the bar.php contain contents e.g.
$global_v1 = "abc";
$global_v2 = "def";
I want to execute function foo(), but at the same time, let the
variables declared in bar.php to have global scopem is it possible?
Thanks.
Re: Export local variable to global variable scope?
am 29.09.2007 15:10:24 von Jerry Stuckle
howa wrote:
> Hello,
>
> I have a function, e.g.
>
> function foo() {
> include("bar.php");
> }
>
> and the bar.php contain contents e.g.
>
> $global_v1 = "abc";
> $global_v2 = "def";
>
> I want to execute function foo(), but at the same time, let the
> variables declared in bar.php to have global scopem is it possible?
>
> Thanks.
>
You should not have an include within a function call. Among other
things, you 'll have problems if you call the function twice.
Actually, globals are bad things to use, anyway.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Export local variable to global variable scope?
am 29.09.2007 19:29:04 von howa
>> you 'll have problems if you call the function twice.
this can be solved by using include_once.
the reason of using function call to include is we want to selectively
include the needed files, prevent include useless files (i.e. factory
method?)
On 9 29 , 9 10 , Jerry Stuckle wrote:
> howa wrote:
> > Hello,
>
> > I have a function, e.g.
>
> > function foo() {
> > include("bar.php");
> > }
>
> > and the bar.php contain contents e.g.
>
> > $global_v1 = "abc";
> > $global_v2 = "def";
>
> > I want to execute function foo(), but at the same time, let the
> > variables declared in bar.php to have global scopem is it possible?
>
> > Thanks.
>
> You should not have an include within a function call. Among other
> things, you 'll have problems if you call the function twice.
>
> Actually, globals are bad things to use, anyway.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
Re: Export local variable to global variable scope?
am 29.09.2007 20:26:33 von Bucky Kaufman
"Bruno Barros" wrote in message
news:1191073761.283822.306170@n39g2000hsh.googlegroups.com.. .
> On 29 Sep, 13:23, howa wrote:
> include "bar.php";
>
> Good enough?
Better to use "requires_once()" or "include_once()".
Re: Export local variable to global variable scope?
am 29.09.2007 20:42:49 von Jerry Stuckle
howa wrote:
>>> you 'll have problems if you call the function twice.
> On 9 29 , 9 10 , Jerry Stuckle wrote:
>> howa wrote:
>>> Hello,
>>> I have a function, e.g.
>>> function foo() {
>>> include("bar.php");
>>> }
>>> and the bar.php contain contents e.g.
>>> $global_v1 = "abc";
>>> $global_v2 = "def";
>>> I want to execute function foo(), but at the same time, let the
>>> variables declared in bar.php to have global scopem is it possible?
>>> Thanks.
>> You should not have an include within a function call. Among other
>> things, you 'll have problems if you call the function twice.
>>
>> Actually, globals are bad things to use, anyway.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
>
>
> this can be solved by using include_once.
>
> the reason of using function call to include is we want to selectively
> include the needed files, prevent include useless files (i.e. factory
> method?)
>
>
(Top posting fixed)
It isn't that much overhead to include an extra file or two. But if you
do that a lot, perhaps you should examine your methods.
And please don't top post. Thanks.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Export local variable to global variable scope?
am 29.09.2007 22:23:29 von ragearc
On 29 Sep, 19:26, "Sanders Kaufman" wrote:
> "Bruno Barros" wrote in message
>
> news:1191073761.283822.306170@n39g2000hsh.googlegroups.com.. .
>
> > On 29 Sep, 13:23, howa wrote:
> > include "bar.php";
>
> > Good enough?
>
> Better to use "requires_once()" or "include_once()".
Yes I know that.
Re: Export local variable to global variable scope?
am 30.09.2007 09:30:04 von howa
>> And please don't top post. Thanks.
I am posting via Google Group, I am no control.
On 9 30 , 2 42 , Jerry Stuckle wrote:
> howa wrote:
> >>> you 'll have problems if you call the function twice.
> > On 9 29 , 9 10 , Jerry Stuckle wrote:
> >> howa wrote:
> >>> Hello,
> >>> I have a function, e.g.
> >>> function foo() {
> >>> include("bar.php");
> >>> }
> >>> and the bar.php contain contents e.g.
> >>> $global_v1 = "abc";
> >>> $global_v2 = "def";
> >>> I want to execute function foo(), but at the same time, let the
> >>> variables declared in bar.php to have global scopem is it possible?
> >>> Thanks.
> >> You should not have an include within a function call. Among other
> >> things, you 'll have problems if you call the function twice.
>
> >> Actually, globals are bad things to use, anyway.
>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================
>
> >
> > this can be solved by using include_once.
> >
> > the reason of using function call to include is we want to selectively
> > include the needed files, prevent include useless files (i.e. factory
> > method?)
> >
> >
>
> (Top posting fixed)
>
> It isn't that much overhead to include an extra file or two. But if you
> do that a lot, perhaps you should examine your methods.
>
> And please don't top post. Thanks.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
Re: Export local variable to global variable scope?
am 30.09.2007 13:10:32 von ragearc
On 30 Sep, 08:30, howa wrote:
> >> And please don't top post. Thanks.
>
> I am posting via Google Group, I am no control.
>
> On 9 30 , 2 42 , Jerry Stuckle wrote:
>
> > howa wrote:
> > >>> you 'll have problems if you call the function twice.
> > > On 9 29 , 9 10 , Jerry Stuckle wrote:
> > >> howa wrote:
> > >>> Hello,
> > >>> I have a function, e.g.
> > >>> function foo() {
> > >>> include("bar.php");
> > >>> }
> > >>> and the bar.php contain contents e.g.
> > >>> $global_v1 = "abc";
> > >>> $global_v2 = "def";
> > >>> I want to execute function foo(), but at the same time, let the
> > >>> variables declared in bar.php to have global scopem is it possible?
> > >>> Thanks.
> > >> You should not have an include within a function call. Among other
> > >> things, you 'll have problems if you call the function twice.
>
> > >> Actually, globals are bad things to use, anyway.
>
> > >> --
> > >> ==================
> > >> Remove the "x" from my email address
> > >> Jerry Stuckle
> > >> JDS Computer Training Corp.
> > >> jstuck...@attglobal.net
> > >> ==================
>
> > > this can be solved by using include_once.
>
> > > the reason of using function call to include is we want to selectively
> > > include the needed files, prevent include useless files (i.e. factory
> > > method?)
>
> > (Top posting fixed)
>
> > It isn't that much overhead to include an extra file or two. But if you
> > do that a lot, perhaps you should examine your methods.
>
> > And please don't top post. Thanks.
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck...@attglobal.net
> > ==================
>
>
I post via Google Groups and never top-posted ;).
Re: Export local variable to global variable scope?
am 30.09.2007 15:01:12 von luiheidsgoeroe
On Sat, 29 Sep 2007 19:27:28 +0200, howa wrote:
> On 9 29 , 9 49 , Bruno Barros wrote:
>> On 29 Sep, 13:23, howa wrote:
>> > I have a function, e.g.
>>
>> > function foo() {
>> > include("bar.php");
>>
>> > }
>>
>> > and the bar.php contain contents e.g.
>>
>> > $global_v1 =3D "abc";
>> > $global_v2 =3D "def";
>>
>> > I want to execute function foo(), but at the same time, let the
>> > variables declared in bar.php to have global scopem is it possible?=
>> function foo() {
>> global $global_v1;
>> global $global_v2;
>>
>> include "bar.php";
>>
>> }
> Assume that I know nothing about the stuffs inside bar.php...is it
> possible?
function foo(){
include_once('bar.php');
foreach(get_defined_vars() as $name =3D> $value){
if(!in_array($name, =
array('_GET','_POST','GLOBALS','_COOKIE','_SESSION','_ENV',' _FILES','_RE=
QUEST','_SERVER')))
$GLOBALS[$name] =3D $value;
}
}
It's really kinda ugly though.
-- =
Rik Wasmus
Re: Export local variable to global variable scope?
am 30.09.2007 15:31:57 von Jerry Stuckle
howa wrote:
>>> And please don't top post. Thanks.
> On 9 30 , 2 42 , Jerry Stuckle wrote:
>> howa wrote:
>>>>> you 'll have problems if you call the function twice.
>>> On 9 29 , 9 10 , Jerry Stuckle wrote:
>>>> howa wrote:
>>>>> Hello,
>>>>> I have a function, e.g.
>>>>> function foo() {
>>>>> include("bar.php");
>>>>> }
>>>>> and the bar.php contain contents e.g.
>>>>> $global_v1 = "abc";
>>>>> $global_v2 = "def";
>>>>> I want to execute function foo(), but at the same time, let the
>>>>> variables declared in bar.php to have global scopem is it possible?
>>>>> Thanks.
>>>> You should not have an include within a function call. Among other
>>>> things, you 'll have problems if you call the function twice.
>>>> Actually, globals are bad things to use, anyway.
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================
>> >
>> > this can be solved by using include_once.
>> >
>> > the reason of using function call to include is we want to selectively
>> > include the needed files, prevent include useless files (i.e. factory
>> > method?)
>> >
>> >
>>
>> (Top posting fixed)
>>
>> It isn't that much overhead to include an extra file or two. But if you
>> do that a lot, perhaps you should examine your methods.
>>
>> And please don't top post. Thanks.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
>
>
> I am posting via Google Group, I am no control.
>
>
>
(Top posting fixed - again).
Here's a clue. There's a key on the right side of your keyboard. It
has a little arrow pointing down.
When you go to reply, you press that key until your cursor is at the end
of the message. Then you start posting your reply.
Other google groupers have figured that out. Why can't you?
A. Because they're either stoopid or just plain lazy.
Q. Why do they continue doing it?
A. People who refuse to post properly.
Q. Who are the most annoying people on the internet?
A. Because it upsets the normal flow of conversation.
Q. Why is it so bad?
A. Top posting.
Q. What is the most annoying thing on usenet?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Export local variable to global variable scope?
am 30.09.2007 15:56:46 von Shelly
"Jerry Stuckle" wrote in message
news:v9udnTXx0NRPOGLbnZ2dnUVZ_o2vnZ2d@comcast.com...
> howa wrote:
>>>> And please don't top post. Thanks.
>> On 9 30 , 2 42 , Jerry Stuckle wrote:
>>> howa wrote:
>>>>>> you 'll have problems if you call the function twice.
>>>> On 9 29 , 9 10 , Jerry Stuckle wrote:
>>>>> howa wrote:
>>>>>> Hello,
>>>>>> I have a function, e.g.
>>>>>> function foo() {
>>>>>> include("bar.php");
>>>>>> }
>>>>>> and the bar.php contain contents e.g.
>>>>>> $global_v1 = "abc";
>>>>>> $global_v2 = "def";
>>>>>> I want to execute function foo(), but at the same time, let the
>>>>>> variables declared in bar.php to have global scopem is it possible?
>>>>>> Thanks.
>>>>> You should not have an include within a function call. Among other
>>>>> things, you 'll have problems if you call the function twice.
>>>>> Actually, globals are bad things to use, anyway.
>>>>> --
>>>>> ==================
>>>>> Remove the "x" from my email address
>>>>> Jerry Stuckle
>>>>> JDS Computer Training Corp.
>>>>> jstuck...@attglobal.net
>>>>> ==================
>>> >
>>> > this can be solved by using include_once.
>>> >
>>> > the reason of using function call to include is we want to
>>> selectively
>>> > include the needed files, prevent include useless files (i.e. factory
>>> > method?)
>>> >
>>> >
>>>
>>> (Top posting fixed)
>>>
>>> It isn't that much overhead to include an extra file or two. But if you
>>> do that a lot, perhaps you should examine your methods.
>>>
>>> And please don't top post. Thanks.
>>>
>>> --
>>> ==================
>>> Remove the "x" from my email address
>>> Jerry Stuckle
>>> JDS Computer Training Corp.
>>> jstuck...@attglobal.net
>>> ==================
>>
>>
> >
> > I am posting via Google Group, I am no control.
> >
> >
> >
>
> (Top posting fixed - again).
>
> Here's a clue. There's a key on the right side of your keyboard. It has
> a little arrow pointing down.
>
> When you go to reply, you press that key until your cursor is at the end
> of the message. Then you start posting your reply.
>
> Other google groupers have figured that out. Why can't you?
>
> A. Because they're either stoopid or just plain lazy.
> Q. Why do they continue doing it?
> A. People who refuse to post properly.
> Q. Who are the most annoying people on the internet?
> A. Because it upsets the normal flow of conversation.
> Q. Why is it so bad?
> A. Top posting.
> Q. What is the most annoying thing on usenet?
Jerry, as you know, I don't normally top post or botton post. I "in-line"
post. However,
(a) It is definitely NOT the most annoying thing on the internet and
(b) There are times when a top post is appropriate, such as a one-line thank
you, etc. It saves the reader from having to scroll down to find the new
message.
There are exceptions to all blanket statements -- including this one :-)
Shelly
Re: Export local variable to global variable scope?
am 30.09.2007 16:03:19 von Jerry Stuckle
Shelly wrote:
> "Jerry Stuckle" wrote in message
> news:v9udnTXx0NRPOGLbnZ2dnUVZ_o2vnZ2d@comcast.com...
>> howa wrote:
>>>>> And please don't top post. Thanks.
>>> On 9 30 , 2 42 , Jerry Stuckle wrote:
>>>> howa wrote:
>>>>>>> you 'll have problems if you call the function twice.
>>>>> On 9 29 , 9 10 , Jerry Stuckle wrote:
>>>>>> howa wrote:
>>>>>>> Hello,
>>>>>>> I have a function, e.g.
>>>>>>> function foo() {
>>>>>>> include("bar.php");
>>>>>>> }
>>>>>>> and the bar.php contain contents e.g.
>>>>>>> $global_v1 = "abc";
>>>>>>> $global_v2 = "def";
>>>>>>> I want to execute function foo(), but at the same time, let the
>>>>>>> variables declared in bar.php to have global scopem is it possible?
>>>>>>> Thanks.
>>>>>> You should not have an include within a function call. Among other
>>>>>> things, you 'll have problems if you call the function twice.
>>>>>> Actually, globals are bad things to use, anyway.
>>>>>> --
>>>>>> ==================
>>>>>> Remove the "x" from my email address
>>>>>> Jerry Stuckle
>>>>>> JDS Computer Training Corp.
>>>>>> jstuck...@attglobal.net
>>>>>> ==================
>>>> >
>>>> > this can be solved by using include_once.
>>>> >
>>>> > the reason of using function call to include is we want to
>>>> selectively
>>>> > include the needed files, prevent include useless files (i.e. factory
>>>> > method?)
>>>> >
>>>> >
>>>>
>>>> (Top posting fixed)
>>>>
>>>> It isn't that much overhead to include an extra file or two. But if you
>>>> do that a lot, perhaps you should examine your methods.
>>>>
>>>> And please don't top post. Thanks.
>>>>
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================
>>>
>>>
>>> I am posting via Google Group, I am no control.
>>>
>>>
>>>
>> (Top posting fixed - again).
>>
>> Here's a clue. There's a key on the right side of your keyboard. It has
>> a little arrow pointing down.
>>
>> When you go to reply, you press that key until your cursor is at the end
>> of the message. Then you start posting your reply.
>>
>> Other google groupers have figured that out. Why can't you?
>>
>> A. Because they're either stoopid or just plain lazy.
>> Q. Why do they continue doing it?
>> A. People who refuse to post properly.
>> Q. Who are the most annoying people on the internet?
>> A. Because it upsets the normal flow of conversation.
>> Q. Why is it so bad?
>> A. Top posting.
>> Q. What is the most annoying thing on usenet?
>
> Jerry, as you know, I don't normally top post or botton post. I "in-line"
> post. However,
> (a) It is definitely NOT the most annoying thing on the internet and
> (b) There are times when a top post is appropriate, such as a one-line thank
> you, etc. It saves the reader from having to scroll down to find the new
> message.
>
> There are exceptions to all blanket statements -- including this one :-)
>
> Shelly
>
>
That's your opinion. A lot of people disagree with you.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Export local variable to global variable scope?
am 30.09.2007 17:22:59 von Bucky Kaufman
"Shelly" wrote in message
news:13fvaq7lj1skj37@corp.supernews.com...
> "Jerry Stuckle" wrote in message
> Jerry, as you know, I don't normally top post or botton post. I "in-line"
> post. However,
> (a) It is definitely NOT the most annoying thing on the internet and
Hahaha.
That's the funniest thing every written on the Internet. ;)
Re: Export local variable to global variable scope?
am 30.09.2007 17:59:30 von ragearc
> Other google groupers have figured that out. Why can't you?
LOL when I post it automatically takes the pointer to the lower part,
so I don't have to press the down button.
And why is top posting so bad? Because of your Usenet Software?
Re: Export local variable to global variable scope?
am 30.09.2007 19:51:01 von Jerry Stuckle
Bruno Barros wrote:
>> Other google groupers have figured that out. Why can't you?
>
> LOL when I post it automatically takes the pointer to the lower part,
> so I don't have to press the down button.
>
> And why is top posting so bad? Because of your Usenet Software?
>
A. Because it upsets the normal flow of conversation.
Q. Why is top posting so bad?
Also, most usenet groups (including this one) have standards about
posting, to make it easier for everyone. And this one includes in-line
or bottom posting, but not top posting.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================