4

I am getting a blank page on a PHP when I use require_once to include another php. This is working, however, on other files. Now, I reduced all my code to this:

echo 'testing';
require_once 'C:/xampp/htdocs/folder/file.php';
echo 'now show this';

The code above just produces a blank page, no errors or anything, even though this file is being used on other files with no problems. I put a trace on the top of that file and nothing. I am using it in the same way the other files are using it, just a require_once.

If I comment file.php to nothing but a line reading echo ' - inside file', the line is displayed, however it is not continuing with the rest. Thus, showing the following output:

testing - inside file

It's not going with the rest... What could be the reason of this?

3
  • 1
    Have you got PHP error reporting turned on? XAMPP doesn't come with it enable by default from memory. ini_set('error_reporting', E_ALL) and ini_set('display_errors', true); placed at the top of the page should do it. Commented Sep 11, 2011 at 23:30
  • why you want to include something with the windows-path and then without backslashes? Commented Sep 11, 2011 at 23:39
  • require stops the script if the file is not found or loaded. use include and exceptions instead. Commented Sep 11, 2011 at 23:45

2 Answers 2

5

Try to enable error reporting on your page. That might shine a light on your problem.

Place this code in your page and let me know if you get any errors.

error_reporting(E_ALL);
ini_set('display_errors', '1');
Sign up to request clarification or add additional context in comments.

2 Comments

No errors... Blank page still with the first code shown in my original post.
You can post the code in file.php, or just include the contents of file.php in the file you showed above. That might make debugging easier. As the comment above, try to use include instead of require.
0

Try checking for whitespace (spaces, new lines, or tabs) in front of opening php tags, and after closing php tags.

Check this for all of your files. I've had problems working with big frameworks and lots of files where a space around a tag would result in the blank screen, but not give feedback pointing to the issue, even with display_errors on and reporting set to E_ALL | E_STRICT

Edit: By 'check', I mean delete them if they are there. :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.