Re: [PHP] how to make a global scope array
Thank you very much! "David Nicholson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, This is a reply to an e-mail that you wrote on Sat, 26 Jul 2003 at 00:50, lines prefixed by '>' were originally written by you. > Ouch! > Sometimes I wish global didn't exist Yes, it can be better to pass in a variable (by reference if you need to write to it from within a function and not have it as the value that you return), e.g. function doSomething(&$a){ $a = 20; return true; // to signify success } $a = 10; doSomething($a); echo $a; // prints 20 -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to make a global scope array
Hello, This is a reply to an e-mail that you wrote on Sat, 26 Jul 2003 at 00:50, lines prefixed by '>' were originally written by you. > Ouch! > Sometimes I wish global didn't exist Yes, it can be better to pass in a variable (by reference if you need to write to it from within a function and not have it as the value that you return), e.g. function doSomething(&$a){ $a = 20; return true; // to signify success } $a = 10; doSomething($a); echo $a; // prints 20 -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to make a global scope array
* Thus wrote Comex ([EMAIL PROTECTED]): > <[EMAIL PROTECTED]> > Jack Lee: > > //I have an array a[] like this: > > > > > $a[]=0; > > > > //How to define and use it in a function like this? > > > > function myfunc(something) > > { > > echo $a[0]; //got error here Notice: Undefined variable: > > > > } > > > >> > > //Thanks for any help.!!! > > global $a; Ouch! Sometimes I wish global didn't exist Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to make a global scope array
It works! Thanks guys! "David Nicholson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, This is a reply to an e-mail that you wrote on Fri, 25 Jul 2003 at 23:51, lines prefixed by '>' were originally written by you. > <[EMAIL PROTECTED]> > Jack Lee: > > //I have an array a[] like this: > > > $a[]=0; > > //How to define and use it in a function like this? > > function myfunc(something) > > { > > echo $a[0]; //got error here Notice: Undefined variable: > > } > > //Thanks for any help.!!! > global $a; .. or echo $GLOBALS['a'][0]; David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to make a global scope array
Hello, This is a reply to an e-mail that you wrote on Fri, 25 Jul 2003 at 23:51, lines prefixed by '>' were originally written by you. > <[EMAIL PROTECTED]> > Jack Lee: > > //I have an array a[] like this: > > > $a[]=0; > > //How to define and use it in a function like this? > > function myfunc(something) > > { > > echo $a[0]; //got error here Notice: Undefined variable: > > } > > //Thanks for any help.!!! > global $a; .. or echo $GLOBALS['a'][0]; David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to make a global scope array
<[EMAIL PROTECTED]> Jack Lee: > //I have an array a[] like this: > > $a[]=0; > > //How to define and use it in a function like this? > > function myfunc(something) > { > echo $a[0]; //got error here Notice: Undefined variable: > > } > >> > //Thanks for any help.!!! global $a; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to make a global scope array
//I have an array a[] like this: //Thanks for any help.!!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php