Jump to content


Photo

**solved** is there?


  • Please log in to reply
5 replies to this topic

#1 Endrew

Endrew
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 21 April 2006 - 01:15 PM

1. Is there any php function that checks variable existence?
2. Is there any php function that refreshes page?
Thnx

#2 bbaker

bbaker
  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 21 April 2006 - 02:01 PM

1. Is there any php function that checks variable existence?

There are ways to check this, not sure if there is a specific function though.
Here's one way to check if a variable exists.
if (!$var){
    echo '$var does not exist';
}
else {
    echo '$var exists!';
}

2. Is there any php function that refreshes page?

No, PHP is a server side language.....use javascript for this.

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 April 2006 - 03:03 PM

[!--quoteo(post=367176:date=Apr 21 2006, 02:15 PM:name=Endrew)--][div class=\'quotetop\']QUOTE(Endrew @ Apr 21 2006, 02:15 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
1. Is there any php function that checks variable existence?
2. Is there any php function that refreshes page?
Thnx
[/quote]
Yes PHP has a function whether a variable exists or not this function is called isset.

For your secound question PHP can refresh the page with the header function ie:
header("Refresh: 5; URL=http://www.google.com");
With the above code your page will refresh after 5 secounds and then it'll take you to google. Just change the number 5 to amount in secounds you wish your page to refresh and change [a href=\"http://www.google.com\" target=\"_blank\"]http://www.google.com[/a] to the site or file you wish your user to be redirected to.

#4 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 21 April 2006 - 03:39 PM

[!--quoteo(post=367192:date=Apr 21 2006, 03:01 PM:name=bbaker)--][div class=\'quotetop\']QUOTE(bbaker @ Apr 21 2006, 03:01 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
if (!$var){
    echo '$var does not exist';
}
else {
    echo '$var exists!';
}

[/quote]

and just to clear the first answer like wildteen cleared up the second, the above is the wrong way to check the existence of a var.
why?
because using ! infront of the var will also be 'true' in the event of the var being either 'false', zero or an empty string. just because a variable has one of these 'nothing' values, doesnt mean it hasnt been set.
as wildteen suggested:

if (isset($var))
{
   echo 'var exists';
}
will do the trick nicely

cheers
Mark
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#5 bbaker

bbaker
  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 22 April 2006 - 01:34 AM

the other posts are absolutely correct....next time, I'll think before I speak. I apologize for the bad info.

#6 Endrew

Endrew
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 23 April 2006 - 12:17 AM

isset works. Thanks a lot for fast reply.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users