Jump to content

include: failed to open stream: No such file or directory (aka "please help")


jimboppin

Recommended Posts

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 by jimboppin
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

<?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 by jimboppin
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.