johnl1479 Posted June 27, 2006 Share Posted June 27, 2006 index.php[code] <?phprequire ("http://inc.johnluetke.net/site_status.php");if (isRestricted("home")) { include ("http://inc.johnluetke.net/unavailable.php"); die();}?>[/code]site_status.php[code] <?phpfunction isRestricted ( $page ) { $restrict = "home"; if ($page == $restrict) { return true; } else if ($restrict == "all") { return true; } else { return false; }}?>[/code]when loading index.php, PHP tells me that isRestricted is undefined....am i missing something? Quote Link to comment https://forums.phpfreaks.com/topic/12994-php-is-being-stupid-undefined-function-exists/ Share on other sites More sharing options...
tiki Posted June 27, 2006 Share Posted June 27, 2006 site_status.php is confusing, why are you comparing home to all? Quote Link to comment https://forums.phpfreaks.com/topic/12994-php-is-being-stupid-undefined-function-exists/#findComment-49956 Share on other sites More sharing options...
johnl1479 Posted June 27, 2006 Author Share Posted June 27, 2006 the purpose of the function is to see if the current part of the site is restricted. the name of the page in question is passed via the $page variable.$restrict is the name of the page that cannot be viewedthe first if statement checks to see if the given page is resrictedthe second sees if the whole site is restricted Quote Link to comment https://forums.phpfreaks.com/topic/12994-php-is-being-stupid-undefined-function-exists/#findComment-50141 Share on other sites More sharing options...
wildteen88 Posted June 27, 2006 Share Posted June 27, 2006 From looking at your code, the secound if is checking whether $restrict is equal to "all", it is not checking whether $page is equal to "all", only the first if is checking the value of $page.Also I have no idea why you're getting the undefined function error message. You are sure that you havn't mistyped the name of the function? Also with your require/include statements you can use relative paths rather then full paths. Quote Link to comment https://forums.phpfreaks.com/topic/12994-php-is-being-stupid-undefined-function-exists/#findComment-50172 Share on other sites More sharing options...
Koobi Posted June 27, 2006 Share Posted June 27, 2006 you're including the file via the HTTP protocol which means your web server (eg: apache) will parse the file which means what you're including will be some form of makrup like HTML and not PHP.if you want the raw PHP code, you would have to include it via the file protocol instead of http so that the PHP is not processed before it's included.eg:[code]<?phprequire ("/path/to/inc.johnluetke.net/site_status.php");if (isRestricted("home")) { include ("http://inc.johnluetke.net/unavailable.php"); die();}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12994-php-is-being-stupid-undefined-function-exists/#findComment-50183 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.