Re: [PHP] Re: Making variable global / accessing variable

2001-10-01 Thread Jason G.

You can see the below code in action at:
http://www.ionzoft.com/code/testing/globals.php

';
echo '$foo_error = ', $foo_error, '';
echo '$foo_ok = ', $foo_ok, '';

echo '';
CreateGlobals("foo");
echo '';

echo 'After Call to CreateGlobals()';
echo '$foo_error = ', $foo_error, '';
echo '$foo_ok = ', $foo_ok, '';

?>



There is probably a better way to do this.
Check the docs on Variable Variables and the {} syntax.



At 10:01 PM 9/30/2001 -0700, Justin Garrett wrote:
>But how would you use this to create new global variables with $td as the
>prefix?
>
>$td = "foo";
>
>then we want new global variables
>
>$foo_error and $foo_ok created.
>
>--
>Justin Garrett
>
>"Jason G." <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >
> > function MyFunction($td)
> > {
> >  global $$td;
> >  echo $$td; // echos 3
> >  $$td = 5;
> > }
> >
> > $billybob = 3;
> > MyFunction("billybob");
> > file://Now $billybob = 5
> >
> > -Jason Garber
> > IonZoft.com
> >
> > At 10:25 PM 9/30/2001 -0400, you wrote:
> >
> > >I have used:
> > >
> > >global $$td;
> > >
> > >in the past with success...
> > >
> > >-Jason Garber
> > >IonZoft.com
> > >
> > >
> > >At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
> > >>Maybe something similar to this?
> > >>
> > >>function test($td){
> > >>
> > >> $global = "global \$$td"."_error, \$$td"."_ok;";
> > >> eval($global);
> > >>
> > >> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
> > >> eval($set);
> > >>}
> > >>
> > >>test("foo");
> > >>echo "$foo_error $foo_ok";
> > >>
> > >>--
> > >>Justin Garrett
> > >>
> > >>"Martin" <[EMAIL PROTECTED]> wrote in message
> > >>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > >> > Hello!
> > >> >
> > >> > How can I make a variable, which name I give to a function, global in
> > >> > this function?
> > >> >
> > >> > I want to make something like:
> > >> >
> > >> > function MyFunc($sVarName)
> > >> > {GLOBAL [$sVarName]_error, $sVarName_ok;
> > >> > 
> > >> > }
> > >> >
> > >> > So if $sVarName = "sHello", I want to access $sHello_error and
> > >> > $sHello_ok in this function.
> > >> >
> > >> > Any idea how I can make this variable gloabl and whats the easyst way
>to
> > >> > access this var then?
> > >> >
> > >> > Martin
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >>--
> > >>PHP General Mailing List (http://www.php.net/)
> > >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >>For additional commands, e-mail: [EMAIL PROTECTED]
> > >>To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > >--
> > >PHP General Mailing List (http://www.php.net/)
> > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >For additional commands, e-mail: [EMAIL PROTECTED]
> > >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> >
> > At 10:25 PM 9/30/2001 -0400, Jason G. wrote:
> >
> > >I have used:
> > >
> > >global $$td;
> > >
> > >in the past with success...
> > >
> > >-Jason Garber
> > >IonZoft.com
> > >
> > >
> > >At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
> > >>Maybe something similar to this?
> > >>
> > >>function test($td){
> > >>
> > >> $global = "global \$$td"."_error, \$$td"."_ok;";
> > >> eval($global);
> > >>
> > >> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
> > >> eval($set);
> > >>}
> > >>
> > >>test("foo");
> > >>echo "$foo_error $foo_ok";
> > >>
> > >>--
> > >>Justin Garrett
> > >>
> > >>"Martin" <[EMAIL PROTECTED]> wrote in message
> > >>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > >> > Hello!
> > >> >
> > >> > How can I make a variable, which name I give to a function, global in
> > >> > this function?
> > >> >
> > >> > I want to make something like:
> > >> >
> > >> > function MyFunc($sVarName)
> > >> > {GLOBAL [$sVarName]_error, $sVarName_ok;
> > >> > 
> > >> > }
> > >> >
> > >> > So if $sVarName = "sHello", I want to access $sHello_error and
> > >> > $sHello_ok in this function.
> > >> >
> > >> > Any idea how I can make this variable gloabl and whats the easyst way
>to
> > >> > access this var then?
> > >> >
> > >> > Martin
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >>--
> > >>PHP General Mailing List (http://www.php.net/)
> > >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >>For additional commands, e-mail: [EMAIL PROTECTED]
> > >>To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > >--
> > >PHP General Mailing List (http://www.php.net/)
> > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >For additional commands, e-mail: [EMAIL PROTECTED]
> > >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> >
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: 

Re: [PHP] Re: Making variable global / accessing variable

2001-09-30 Thread Justin Garrett

But how would you use this to create new global variables with $td as the
prefix?

$td = "foo";

then we want new global variables

$foo_error and $foo_ok created.

--
Justin Garrett

"Jason G." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> function MyFunction($td)
> {
>  global $$td;
>  echo $$td; // echos 3
>  $$td = 5;
> }
>
> $billybob = 3;
> MyFunction("billybob");
> file://Now $billybob = 5
>
> -Jason Garber
> IonZoft.com
>
> At 10:25 PM 9/30/2001 -0400, you wrote:
>
> >I have used:
> >
> >global $$td;
> >
> >in the past with success...
> >
> >-Jason Garber
> >IonZoft.com
> >
> >
> >At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
> >>Maybe something similar to this?
> >>
> >>function test($td){
> >>
> >> $global = "global \$$td"."_error, \$$td"."_ok;";
> >> eval($global);
> >>
> >> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
> >> eval($set);
> >>}
> >>
> >>test("foo");
> >>echo "$foo_error $foo_ok";
> >>
> >>--
> >>Justin Garrett
> >>
> >>"Martin" <[EMAIL PROTECTED]> wrote in message
> >>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >> > Hello!
> >> >
> >> > How can I make a variable, which name I give to a function, global in
> >> > this function?
> >> >
> >> > I want to make something like:
> >> >
> >> > function MyFunc($sVarName)
> >> > {GLOBAL [$sVarName]_error, $sVarName_ok;
> >> > 
> >> > }
> >> >
> >> > So if $sVarName = "sHello", I want to access $sHello_error and
> >> > $sHello_ok in this function.
> >> >
> >> > Any idea how I can make this variable gloabl and whats the easyst way
to
> >> > access this var then?
> >> >
> >> > Martin
> >> >
> >> >
> >>
> >>
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
> At 10:25 PM 9/30/2001 -0400, Jason G. wrote:
>
> >I have used:
> >
> >global $$td;
> >
> >in the past with success...
> >
> >-Jason Garber
> >IonZoft.com
> >
> >
> >At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
> >>Maybe something similar to this?
> >>
> >>function test($td){
> >>
> >> $global = "global \$$td"."_error, \$$td"."_ok;";
> >> eval($global);
> >>
> >> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
> >> eval($set);
> >>}
> >>
> >>test("foo");
> >>echo "$foo_error $foo_ok";
> >>
> >>--
> >>Justin Garrett
> >>
> >>"Martin" <[EMAIL PROTECTED]> wrote in message
> >>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >> > Hello!
> >> >
> >> > How can I make a variable, which name I give to a function, global in
> >> > this function?
> >> >
> >> > I want to make something like:
> >> >
> >> > function MyFunc($sVarName)
> >> > {GLOBAL [$sVarName]_error, $sVarName_ok;
> >> > 
> >> > }
> >> >
> >> > So if $sVarName = "sHello", I want to access $sHello_error and
> >> > $sHello_ok in this function.
> >> >
> >> > Any idea how I can make this variable gloabl and whats the easyst way
to
> >> > access this var then?
> >> >
> >> > Martin
> >> >
> >> >
> >>
> >>
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Making variable global / accessing variable

2001-09-30 Thread Jason G.


function MyFunction($td)
{
 global $$td;
 echo $$td; // echos 3
 $$td = 5;
}

$billybob = 3;
MyFunction("billybob");
//Now $billybob = 5

-Jason Garber
IonZoft.com

At 10:25 PM 9/30/2001 -0400, you wrote:

>I have used:
>
>global $$td;
>
>in the past with success...
>
>-Jason Garber
>IonZoft.com
>
>
>At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
>>Maybe something similar to this?
>>
>>function test($td){
>>
>> $global = "global \$$td"."_error, \$$td"."_ok;";
>> eval($global);
>>
>> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
>> eval($set);
>>}
>>
>>test("foo");
>>echo "$foo_error $foo_ok";
>>
>>--
>>Justin Garrett
>>
>>"Martin" <[EMAIL PROTECTED]> wrote in message
>>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> > Hello!
>> >
>> > How can I make a variable, which name I give to a function, global in
>> > this function?
>> >
>> > I want to make something like:
>> >
>> > function MyFunc($sVarName)
>> > {GLOBAL [$sVarName]_error, $sVarName_ok;
>> > 
>> > }
>> >
>> > So if $sVarName = "sHello", I want to access $sHello_error and
>> > $sHello_ok in this function.
>> >
>> > Any idea how I can make this variable gloabl and whats the easyst way to
>> > access this var then?
>> >
>> > Martin
>> >
>> >
>>
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

At 10:25 PM 9/30/2001 -0400, Jason G. wrote:

>I have used:
>
>global $$td;
>
>in the past with success...
>
>-Jason Garber
>IonZoft.com
>
>
>At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
>>Maybe something similar to this?
>>
>>function test($td){
>>
>> $global = "global \$$td"."_error, \$$td"."_ok;";
>> eval($global);
>>
>> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
>> eval($set);
>>}
>>
>>test("foo");
>>echo "$foo_error $foo_ok";
>>
>>--
>>Justin Garrett
>>
>>"Martin" <[EMAIL PROTECTED]> wrote in message
>>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> > Hello!
>> >
>> > How can I make a variable, which name I give to a function, global in
>> > this function?
>> >
>> > I want to make something like:
>> >
>> > function MyFunc($sVarName)
>> > {GLOBAL [$sVarName]_error, $sVarName_ok;
>> > 
>> > }
>> >
>> > So if $sVarName = "sHello", I want to access $sHello_error and
>> > $sHello_ok in this function.
>> >
>> > Any idea how I can make this variable gloabl and whats the easyst way to
>> > access this var then?
>> >
>> > Martin
>> >
>> >
>>
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Making variable global / accessing variable

2001-09-30 Thread Jason G.


I have used:

global $$td;

in the past with success...

-Jason Garber
IonZoft.com


At 07:38 PM 9/30/2001 -0700, Justin Garrett wrote:
>Maybe something similar to this?
>
>function test($td){
>
> $global = "global \$$td"."_error, \$$td"."_ok;";
> eval($global);
>
> $set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
> eval($set);
>}
>
>test("foo");
>echo "$foo_error $foo_ok";
>
>--
>Justin Garrett
>
>"Martin" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hello!
> >
> > How can I make a variable, which name I give to a function, global in
> > this function?
> >
> > I want to make something like:
> >
> > function MyFunc($sVarName)
> > {GLOBAL [$sVarName]_error, $sVarName_ok;
> > 
> > }
> >
> > So if $sVarName = "sHello", I want to access $sHello_error and
> > $sHello_ok in this function.
> >
> > Any idea how I can make this variable gloabl and whats the easyst way to
> > access this var then?
> >
> > Martin
> >
> >
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Making variable global / accessing variable

2001-09-30 Thread Justin Garrett

Maybe something similar to this?

function test($td){

$global = "global \$$td"."_error, \$$td"."_ok;";
eval($global);

$set = "\$$td"."_error = \"ERROR\"; \$$td"."_ok = \"OK\";";
eval($set);
}

test("foo");
echo "$foo_error $foo_ok";

--
Justin Garrett

"Martin" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello!
>
> How can I make a variable, which name I give to a function, global in
> this function?
>
> I want to make something like:
>
> function MyFunc($sVarName)
> {GLOBAL [$sVarName]_error, $sVarName_ok;
> 
> }
>
> So if $sVarName = "sHello", I want to access $sHello_error and
> $sHello_ok in this function.
>
> Any idea how I can make this variable gloabl and whats the easyst way to
> access this var then?
>
> Martin
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]