要求和包含无法查找和打开文件PHP 5.5.5

Running PHP 5.5.5 FPM/FastCGI on CentOS 6.4 x64 with Nginx.

require_once(dirname(__FILE__) . '/adminsetting.php') or die();

returns the following error:

PHP Fatal error:  require_once(): Failed opening required '1'
(include_path='.:/usr/share/pear:/usr/share/php') in
/home/vincek/public_html/plg/index.php on line 4

The file adminsetting.php is located in the same dir as index.php and exists.

I've double checked everything I can think of, php is running under the current user, all the ownership and permissions are correct.

I can't figure out why this file cannot be found.

Do I need a separate location block in my vhost.conf for this directory?

--EDIT-- Additional code was requested:

from index.php:

session_start();
$base_path=substr($_SERVER['SCRIPT_FILENAME'] , 0 , -strlen($_SERVER['PHP_SELF'])+0).dirname($_SERVER['PHP_SELF']);
require_once(dirname(__FILE__) . '/adminsetting.php');
setcookie("usercheck", " ", time()-60*5);
include($require_path."/functions.php");
if($datastoreselected=="2")include_once($mysql_path."/connection.php");
include("header.php");
include("side.php");
... etc ...

From adminsetting.php:

$root_path="/home/vincek/public_html/plg";
$base_path="/home/vincek/public_html/plg";
$adminurl="http://vincek.co";
$admininstalldirectory="/plg";
$base_url="http://vincek.co/plg/";
$site_title="Power Link Generator v4.8";
$require_path="/home/vincek/public_html/plg/include";
$template_path="/home/vincek/public_html/plg/templates";
$mysql_path="/home/vincek/public_html/plg/mysql";
$image_path="http://vincek.co/plg/images";
$adminbase="/home/vincek/public_html/";
... etc ...

IF the adminsetting file is being included ... why would the called variables not be found?

Require does not return a value, so it will always die at your or die(). Use

require_once(dirname(__FILE__) . '/adminsetting.php');

If it fails, it will cause a fatal error anyway. That's what require does: it includes a script, or dies on failure

EDIT:

Your adminsetting file is being interpreted as text and I can't understand why. It may have some character that is messing with you <? code blocks. I've seen it happen with XML files having a null character (after some wiseguy edited the XML file with Word, and waited for my parser to do the rest). My best suggestion for now is to move the adminsetting file somewhere else, create a new adminsetting file, write the php code blocks yourself and just copy the rest of the code in the new file. The problem has to be the adminsetting file, nothing else.

The trap is that require_once is a statement, not a function, so the brackets around the filename are misleading. What actually runs is the same as require_once ('something.php' or die); which becomes require_once true; and thence require_once '1';, which explains the error message.

As others have pointed out, require_once will die on its own anyway, but if you did want to use include_once with this idiom, you need to arrange the brackets differently: (include_once 'something.php') or die;

change

<?

to

<?php

in your included file.

<? can't be used in the latest php releases (if you do not make configuration changes).