You are here: Re: Scope « All PHP « IT news, forums, messages
Re: Scope

Posted by Steve on 11/07/06 15:41

"Steve" <no.one@example.com> wrote in message
news:KC14h.12$Xl1.6@newsfe02.lga...
|| As I understand scope in php, variables are local unless otherwise stated
|| with a "global $var;". This is different from other languages I've
|| encountered, but it is no more or less confusing. As for your question
| about
|| getting a value from a function that's in an included file, I'd like to
| say
|| that it doesn't matter where the function is, so long as it is available
| to
|| your script, and "return" has nothing at all to do with scope. If you
are
|| getting unecpected results, the problem is in the code. I expect that you
|| simply haven't declaired variables as being global when you should have,
| or
|| that you are changing a local copy of a global variable, thinking your
|| changing the global variable. Something simply infuriating like that. It
|| really is best to avoid globals though, they cause nothing but trouble.
|
| actually, tony, j.aho's reply was the most accurately concise description
of
| scope that i've seen. also, "return" is ENTIRELY in the realm of
discussion
| of scope! what's the difference between returning a copy of a value versus
a
| pointer to where a value resides? SCOPE.
|
| don't get caught up on the op's use of the word "global". it has little to
| do with his actual problem. either way, i hardly see a case for saying
using
| globals are a bad idea. what's the difference in a public, static variable
| of a class and a global variable? SYNTAX. (and the version of php you're
| using ;^)
|
| had you read the op's question thouroughly, you wouldn't "expect that you
| [he] simply haven't [hasn't] declaired [sic] variables as being global
when
| you [he] should have". this only shows you didn't look at his code at
| all...or didn't understand it at all. his function example takes a
parameter
| in lieu of using global...which is good. in his example, the parameter is
| $_POST. you also failed to notice that he is not changing a local copy of
a
| global variable...the op is RETURNING a value from within the $_POST array
| via his function.
|
| either take time to read the op's problem, question, and code, or don't
| bother posting a reply.


DAMN FUCKING OE !!! perhaps you did read the correct thread afterall! i saw
your post show up under another tread that is similar in topic. anyway...ALL
applies except the last two paragraphs even still. ;^)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация