jimboppin Posted October 30, 2016 Author Share Posted October 30, 2016 is my code ready for best answer ? Its works perfect for me i just want it to be clean so people can use it... Jimbo. Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538773 Share on other sites More sharing options...
jimboppin Posted October 30, 2016 Author Share Posted October 30, 2016 (edited) i keep messing with it lol, how am i doing ??? <?php // Directory Of Page_Include const INCLUDE_BASEDIR = __DIR__.'/page_include/'; // Directory Of Pages const PAGES_BASEDIR = __DIR__.'/pages/'; $FILE_EXTENTION = '.php'; $ERROR_404 = 'Error404'.$FILE_EXTENTION.''; $DEFAULT_PAGE = 'home'.$FILE_EXTENTION.''; $LINK_NAME = 'page'; require_once INCLUDE_BASEDIR.'page_config'.$FILE_EXTENTION.''; if ($detect->isMobile()) { header('Location: mobile'.$FILE_EXTENTION.''); exit(0); } const PAGES = [ // Array Of Active Pages 'home', ]; if (!isset($_GET[''.$LINK_NAME.''])) { // Default Index Page require PAGES_BASEDIR.$DEFAULT_PAGE; } else if (in_array($_GET[''.$LINK_NAME.''], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET[''.$LINK_NAME.''].''.$FILE_EXTENTION.'')) { // Displays The Called Link require PAGES_BASEDIR.$_GET[''.$LINK_NAME.''].''.$FILE_EXTENTION.''; } else { http_response_code(404); // Display Error404 Page require PAGES_BASEDIR.$ERROR_404; } //END OF CONTENT require INCLUDE_BASEDIR.'page_footer'.$FILE_EXTENTION.''; ?> Jimbo Edited October 30, 2016 by jimboppin Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538783 Share on other sites More sharing options...
Jacques1 Posted October 30, 2016 Share Posted October 30, 2016 KISS You've produced a lot of extra code without any obvious benefit. For example, how is 'home'.$FILE_EXTENTION.'' better than a simple 'home.php'? It doesn't make the code any clearer (to the contrary), and the chances of ever having to change the file extension to something other than “.php” are pretty slim. And what's up with the empty string at the end? Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538789 Share on other sites More sharing options...
jimboppin Posted October 30, 2016 Author Share Posted October 30, 2016 haha ok maybe not need to do that that... empty string? i dont understand? jimbo. Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538795 Share on other sites More sharing options...
Barand Posted October 30, 2016 Share Posted October 30, 2016 The question is if (!isset($_GET[''.$LINK_NAME.''] ^ ^ | | +------------+-- WTF are these for? Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538797 Share on other sites More sharing options...
jimboppin Posted October 30, 2016 Author Share Posted October 30, 2016 (edited) <?php // Directory Of Page_Include const INCLUDE_BASEDIR = __DIR__.'/page_include/'; // Directory Of Pages const PAGES_BASEDIR = __DIR__.'/pages/'; require_once INCLUDE_BASEDIR.'page_config.php'; if ($detect->isMobile()) { header('Location: mobile.php'); exit(0); } const PAGES = [ // Array Of Active Pages 'home', 'our_world', ]; if (!isset($_GET['page'])) { // Default Index Page require PAGES_BASEDIR.$DEFAULT_PAGE; } else if (in_array($_GET['page'], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET['page'].'.php')) { // Displays The Called Link require PAGES_BASEDIR.$_GET['page'].'.php'; } else { http_response_code(404); // Display Error404 Page require PAGES_BASEDIR.$ERROR_404; } //END OF CONTENT require INCLUDE_BASEDIR.'page_footer.php'; ?> is this better? if (!isset($_GET[''.$LINK_NAME.''] ^ ^ | | +------------+-- WTF are these for? not for anything i was just playign with it to see what i can do.. LEARNING OVER HERE! wtf are you so rude for? arse. Jimbo. Edited October 30, 2016 by jimboppin Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538799 Share on other sites More sharing options...
Barand Posted October 31, 2016 Share Posted October 31, 2016 Sorry for pointing out those unnecessary aspects of your code. I was merely asking why you thought the concatenation of the empty strings was required. No rudeness was intended, unlike your response.I appreciate you must feel an absolute idiot right now, and I am sure no one will deny that you have every right to do so. After all, it was your code so no one else is to blame. Your subsequent petulant behaviour and hurling of profanities at other members (against forum rules by the way) merely reinforces that opinion. 1 Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538821 Share on other sites More sharing options...
jimboppin Posted October 31, 2016 Author Share Posted October 31, 2016 you said "WTF are these for?" like im suposed to know... cos your better you like to make yourself feel good laughing in your chair becouse some one else dosont know how to write code? witch is why im here to learn not be spoke to like a fool. im off. thankyou for the help to this point ill find my help else where. Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538835 Share on other sites More sharing options...
ginerjm Posted October 31, 2016 Share Posted October 31, 2016 Good because I'm getting tired of your unexplainably poor English. You haven't mastered that yet and you want to learn a new language?? Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538837 Share on other sites More sharing options...
Barand Posted October 31, 2016 Share Posted October 31, 2016 ... like im suposed to know... If it were your own code you'd know exactly why it was there. It seems your idea of "programming" is to copy bad code from from the internet and, when it doesn't do what you want, post it here for us to get it working for you. That being the case, thank you for moving on elsewhere. On the other hand, if and when you get serious about learning, we'll be happy to help. Quote Link to comment https://forums.phpfreaks.com/topic/302412-include-failed-to-open-stream-no-such-file-or-directory-aka-please-help/page/2/#findComment-1538839 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.