[PHP] newbie... - undefined var

2002-08-26 Thread Matt Zur

I'm just starting to learn php and have a quick question. I'm making a 
site with file includes.  so for example my default page will be:
index.php and services page with be called services.php

BUT... I want to link to services via this method:  index.php?vw=services

Still no problem there.

BUT on the index.php I want to write this if statement:

if ($vw == ) {
write this code
}

But then I get an error that the var is non defined.  Do all vars in PHP 
have to be defined first?  If it isn't defined, doesn't the program 
assume it's value is nothing?

-Matt

-- 
Matt Zur
[EMAIL PROTECTED]
http://www.zurnet.com

Need a Web Site??? - Visit... www.zurnet.com

1997 - 2002 - 5th Anniversary!!!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newbie... - undefined var

2002-08-26 Thread Chris Shiflett

Matt Zur wrote:

 BUT on the index.php I want to write this if statement:

 if ($vw == ) {
 write this code
 } 


If you really mean to see if the variable has been set, try this instead:

if (!isset($vw))
{
 echo variable is not set;
}

Happy hacking.

Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




FW: [PHP] newbie... - undefined var

2002-08-26 Thread Jonni

try using a switch statement.  
 
?
   switch($vw)
 {
case :
include intro.php;
break; 
case services:
include services.php;
break;
case next:
include next.php;
default:
include error.php;
break;
  }
 ?
 
 -Original Message-
 From: Matt Zur [mailto:[EMAIL PROTECTED]]
 Sent: Monday, August 26, 2002 12:41 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] newbie... - undefined var
 
 
 I'm just starting to learn php and have a quick question. I'm making a 
 site with file includes.  so for example my default page will be:
 index.php and services page with be called services.php
 
 BUT... I want to link to services via this method:  
 index.php?vw=services
 
 Still no problem there.
 
 BUT on the index.php I want to write this if statement:
 
 if ($vw == ) {
 write this code
 }
 
 But then I get an error that the var is non defined.  Do all 
 vars in PHP 
 have to be defined first?  If it isn't defined, doesn't the program 
 assume it's value is nothing?
 
 -Matt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newbie... - undefined var

2002-08-26 Thread @ Edwin
Or, perhaps, you should do: (if register_globals off)

  if (!isset($_GET['vw'])){
echo "variable is not set";
  }

Of course, you can also do: (if you want to--for some reason)

  if ($_GET['vw'] == ""){
write this code
  }

- E

PS
 Do all vars in PHP have to be defined first?

No.


Matt Zur wrote:

BUT on the index.php I want to write this if statement:

if ($vw == "") {
write this code
}


If you really mean to see if the variable has been set, try this 
instead:

if (!isset($vw))
{
 echo "variable is not set";
}

Happy hacking.

Chris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




_
最新のファイナンス情報とライフプランのアドバイス MSN マネー 
http://money.msn.co.jp/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php