2

I have a little problem, I have a php file that start like this:

<?php
ini_set("display_errors", true);
echo "test"; 
exit(); 

Somehow this returns an empty page?!

I use ubuntu 10.10, gvim and apache2

Can this have something to do with utf-8 formatting? I just switched to ubuntu and gvim so I am not sure if I use utf-8 or not, but I know it has been known to cause this problem.

EDIT:

When I change the file to

<?php
test

Nothing shows up, but if I change it to:

test
<?php

test shows up ?!

5
  • 3
    If you right click on page and view the source what do you see? if you see your php code you need to install php/configure apache to use php for .php files Commented Mar 2, 2011 at 23:51
  • soure is blank and all my other pages work (php pages), I have modified the php file today in linux with gvim. That must have caused the problem.. Commented Mar 2, 2011 at 23:54
  • so one page, valid url, on the server fails, and the rest are all fine? Commented Mar 3, 2011 at 0:10
  • Can we assume you have closed the PHP code (?>)? Try running the code from the command line interface and that might display an error that isn't showing via the browser. Commented Mar 3, 2011 at 0:18
  • You may have spurious characters, or utf8 chars that look similar. Try retyping it from scratch. Commented Mar 3, 2011 at 0:36

2 Answers 2

6

Try replacing the start of your script with this:

<?php
ini_set("display_errors", true);
error_reporting( E_ALL );
echo "test";

If you still have a blank output, create a new file and copy-paste the content of the faulty file across one line/section/control structure at a time, executing the script after each section is transferred. The section you transfer before you get a blank output is probably your cuprit.

Also, try looking at your Error Logs - they may contain details of the error being experienced and causing the blank output. (In fact, I'd do that first.)

Also, with reference to the code snippets included in your original question:

<?php
test

Will always fail, as it is not correct syntax.

<?php
echo 'test';

Should result in "test" being printed to the screen.

Sign up to request clarification or add additional context in comments.

2 Comments

The E_all is apparently not set by default in apache2 in ubuntu, but is set by default in xampp in windows. Found the error now..
These lines helped me using IIS as well.
0

For other people who may have the same problem as me: my PHP script tags were not well-formed! Bad: <? php> instead of good: <?php>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.