Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 888197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:21:23+00:00 2026-05-15T13:21:23+00:00

Am having problems with PHP’s require_once, require, include_once and include functions not correctly resolving

  • 0

Am having problems with PHP’s require_once, require, include_once and include functions not correctly resolving a file. I am running PHP 5.3.1 on Windows Vista with Apache 2.2.11.

These are the problems I am getting:

file_exists('C:/wamp/www/park_factor_network/system/application/shared/config/language.php')

returns TRUE

is_readable('system/application/shared/config/language.php')

returns TRUE

$fp = fopen('C:/wamp/www/park_factor_network/system/application/shared/config/language.php','r');
$contents = fread($fp, filesize('C:/wamp/www/park_factor_network/system/application/shared/config/language.php'));

returns a valid file resource and stores it into $contents

However:

require_once('system/application/shared/config/database.php') or die("Cannot Include Language Config");
require_once('C:/wamp/www/park_factor_network/system/application/shared/config/language.php') or die("Cannot Include Language Config");

return:

Fatal error: require_once() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in C:\wamp\www\park_factor_network\system\application\shared\hooks\select_language.php on line 25

C:\wamp\www\park_factor_network\system\application\news_site\hooks is a Directory Junction for C:\wamp\www\park_factor_network\system\application\shared\hooks

I only experience this problem when accessing this file from a certain location in the framework, however as this is a direct include or require it shouldn’t be affected by that and only PHP? If I try and include the file anywhere else within my setup it loads fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:21:23+00:00Added an answer on May 15, 2026 at 1:21 pm

    require_once is a language construct. It is not a function and has no return value.

    Brackets around the file name parameter are optional. This seems to mean that in this line:

    require_once('system/application/shared/config/database.php') 
                 or die("Cannot Include Language Config");
    

    the whole expression

    ('system/application/shared/config/database.php') 
     or die("Cannot Include Language Config");
    

    is evaluated (returning 1) and used as the file name argument. 1, obviously, doesn’t exist.

    What you are doing doesn’t make real sense though, because include will not return false when loading a file fails. require_once() will terminate the script’s execution anyway. If you take care of switching of error reporting in your production environment, you could easily live with a PHP Fatal Error telling you the file doesn’t exist (instead of your custom die()).

    If you need to gracefully exit the script, I would do a file_exists call before the statement, and die() when that fails:

    $file = 'system/application/shared/config/database.php';
    
    if ((!is_file($file)) or(!is_readable($file)))
       die("Cannot Include Language Config");
    
    require_once('system/application/shared/config/database.php');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems with the hosts file and PHP. When running the PHP code
I've been having a few problems running PHP-based utilities within the command line ever
I am having problems with jQuery Ajax and PHP I have my php file
I'm having problems with changing my configuration file config.php . At the moment, I'm
Im having problems passing PHP Strings to Javascript functions, I'v read a number of
I'm having problems reading lines from a text file in PHP. I have this
I'm having some problems with my PHP server. Most of the functions when run
I'm having problems putting two where statements together My current code: include 'config.php'; $result22
I'm having problems embedding php inside an html file. I first ran in to
I having problems when I am trying to parse emails through PHP imap functions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.