rbaba99@caramail.com (sam) wrote in message news:<fd2aa5c7.0307071335.7149f2dc@posting.google. com>...[color=blue]
> Use the function isset to test if a variable is set :
>
> if(isset($this->HTTP_POST_VARS[$var]))
> {
>
> }
> elseif(isset($this->HTTP_GET_VARS[$var]))
> {
>
> }[/color]
I don't understand how this could much improve things, though I do
understand that in some technical sense it is better syntax for the
test I want to do. Perhaps I'll try it when I've spare time today.
However, you miss the main thing I'm curious about
: as a function in
procedural code, this function works well and has never failed me. Now
that I'm trying to make it the method of an object, it has stopped
working. I'm looking for something that is specific to the object that
would cause it not to work. I've already checked what I thought was
obvious: do the variables have scope here, am I using the "$this->"
syntax. It seems I've done all that, yet the code won't work, and, as
I say, it works well as a function outside of this class.
For now, I've gone back to using getVar, the function, rather than
$io->getVar, the class method. But as I'm moving to OO, I'd like to
figure out how to make this function work as a class method.
[color=blue]
> ........
>
> Hope this helps
>
>
>
lkrubner@geocities.com (lawrence) wrote in message news:<da7e68e8.0307051057.6060f1fa@posting.google. com>...[color=green]
> > I've this function, which is the method of a class. I'm posting the
> > constructor of the class down below. For some reason, when I fill out
> > a form and hit submit, I'm not getting any values. Can someone tell me
> > why?
> >
> >
> >
> >
> > function getVar($var="password") {
> > // 05-08-03 - the important thing about this function is it reverses
> > PHP's built-in load
> > // order for variables. PHP usually loads COOKIE last, so if you've
> > a competing POST and
> > // COOKIE, the POST loses. This is nuts, in my opinion, if someone
> > just posted a form, you
> > // almost always want that to have top priority. And that is what
> > this function does.
> >
> > // 05-27-03 - I just discovered user created globals go in a var
> > called $GLOBALS which has been around
> > // since PHP 3.0. Even though it is old, I'm putting it at the end,
> > partly for security, but also
> > // because it is auto-global and therefore belongs with the other
> > auto-globals.
> >
> > if ($this->HTTP_POST_VARS[$var]) {
> > $value = $this->HTTP_POST_VARS[$var];
> > echo "here is the value of post vars: $value";
> > } elseif ($this->HTTP_GET_VARS[$var]) {
> > $value = $this->HTTP_GET_VARS[$var];
> > echo $value;
> > } elseif ($this->HTTP_ENV_VARS[$var]) {
> > $value = $this->HTTP_ENV_VARS[$var];
> > echo $value;
> > } elseif ($this->HTTP_SERVER_VARS[$var]) {
> > $value = $this->HTTP_SERVER_VARS[$var];
> > echo $value;
> > } elseif ($this->HTTP_COOKIE_VARS[$var]) {
> > $value = $this->HTTP_COOKIE_VARS[$var];
> > echo $value;
> > } elseif ($_POST[$var]) {
> > $value = $_POST[$var];
> > echo $value;
> > } elseif ($_GET[$var]) {
> > $value = $_GET[$var];
> > echo $value;
> > } elseif ($_ENV[$var]) {
> > $value = $ENV[$var];
> > echo $value;
> > } elseif ($_SERVER[$var]) {
> > $value = $_SERVER[$var];
> > echo $value;
> > } elseif ($_COOKIE[$var]) {
> > $value = $_COOKIE[$var];
> > echo $value;
> > } elseif ($GLOBALS[$var]) {
> > $value = $GLOBALS[$var];
> > echo $value;
> > }[/color]
> return $value;[color=green]
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > function McInputOutput() {
> > // 06-20-03 - the global keyword doesn't work inside of objects, and
> > so we must use this
> > // method to get these old variables. You might ask, "Why not just
> > go with the new Super
> > // Globals, like $_GET?" The answer is that I've installed this cms
> > on a suprising number of
> > // hosts running old versions of PHP that don't support the new auto
> > globals. So it is good
> > // to be backwards compatible.
> > $this->HTTP_SERVER_VARS = $GLOBALS["HTTP_SERVER_VARS"];
> > $this->HTTP_POST_VARS = $GLOBALS["HTTP_POST_VARS"];
> > $this->HTTP_GET_VARS = $GLOBALS["HTTP_GET_VARS"];
> > $this->HTTP_COOKIE_VARS = $GLOBALS["HTTP_COOKIE_VARS"];
> > $this->HTTP_ENV_VARS = $GLOBALS["HTTP_ENV_VARS"];
> >
> > $this->id = 1;
> > }[/color][/color]