Endrew Posted April 21, 2006 Share Posted April 21, 2006 1. Is there any php function that checks variable existence?2. Is there any php function that refreshes page?Thnx Quote Link to comment Share on other sites More sharing options...
bbaker Posted April 21, 2006 Share Posted April 21, 2006 [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. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 21, 2006 Share Posted April 21, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted April 21, 2006 Share Posted April 21, 2006 [!--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 nicelycheersMark Quote Link to comment Share on other sites More sharing options...
bbaker Posted April 22, 2006 Share Posted April 22, 2006 the other posts are absolutely correct....next time, I'll think before I speak. I apologize for the bad info. Quote Link to comment Share on other sites More sharing options...
Endrew Posted April 23, 2006 Author Share Posted April 23, 2006 isset works. Thanks a lot for fast reply. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.