/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] include() don’t find the file

Hi all!

I’m having a headache over this… I try to include a local php file, but it fails silently. If I dump the file with file_get_contents() it looks totally correct, though.

[CODE]include(“/absolute/path/to/file.php”); //won’t work

eval(file_get_contents(“/absolute/path/to/file.php”)); //works as expected[/CODE]

What am I not seeing??? I guess it’s something obvious.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 14.2008 — Try something like this to see if it's a config issue.
[code=php]
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
include '/absolute/path/to/file.php';
?>
[/code]
Copy linkTweet thisAlerts:
@legendxJun 14.2008 — require() would also stop the page from working all together but I can't remember if it would print an error with error_reporting turned off.
Copy linkTweet thisAlerts:
@turborakettiauthorJun 15.2008 — Thanks for your advice! It put me in the right direction and the problem is solved, even though it was a really rediculous error... I followed NogDog's suggestion, but it gave only notices on the screen. Finally I installed the php-cli package and found a silly parse error in my file.php by running php -l file.php at prompt. The error didn't show on my local test server (due to slightly different version of php?).

It seems that if I include() a file that won't parse, it silently ignores it and goes on. According to the include() manual at docs.php.net that is the behaviour of PHP prior to 4.3.5. Strange, 'cause I use PHP5...

Lastly, I can't explain why my eval(file_get_contents()) test above would work. I must have been mistaken.

All the same, thanks for replying!
×

Success!

Help @turboraketti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...