Jump to content

**solved** is there?


Endrew

Recommended Posts

[b][i]1. Is there any php function that checks variable existence?[/i][/b]

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.
[code]
if (!$var){
    echo '$var does not exist';
}
else {
    echo '$var exists!';
}

[/code]
[b][i]2. Is there any php function that refreshes page?[/i][/b]

No, PHP is a server side language.....use javascript for this.
Link to comment
https://forums.phpfreaks.com/topic/8039-solved-is-there/#findComment-29333
Share on other sites

[!--quoteo(post=367176:date=Apr 21 2006, 02:15 PM:name=Endrew)--][div class=\'quotetop\']QUOTE(Endrew @ Apr 21 2006, 02:15 PM) [snapback]367176[/snapback][/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 [b]isset[/b].

For your secound question PHP can refresh the page with the header function ie:
[code]header("Refresh: 5; URL=http://www.google.com");[/code]
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.
Link to comment
https://forums.phpfreaks.com/topic/8039-solved-is-there/#findComment-29351
Share on other sites

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

[/code]
[/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:

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

cheers
Mark
Link to comment
https://forums.phpfreaks.com/topic/8039-solved-is-there/#findComment-29359
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.