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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.