PHP代码在firefox中没有结果?

Just started learning Php on my own, and got stuck at the beginning. This is the code I was compiling:

<?php
  echo "Hello world!";
  echo 6+2;
?>

The problem is that the Php portion isn't displayed in Firefox. Why? Firefox ver. 7.0.1., I am using NetBeans 7, with cygwin.

You said you're accessing the file directly like file:///C:/xampp/htdocs/PhpVjezba1/test1.php

Don't do that, access it via http://localhost/PhpVjexba1/test1.php, provided you have a server installed.

Click Here

Probably a stupid question, but are you running PHP from web server or actually trying to run the file directly in browser?

PHP is never displayed in any web browser, it is executed on a web server, and is used (somewhat) to produce html that is displayed to you're web browser.

Do you have a local browser such as wamp?

Does the output display in other browsers?

Does your page have the .php extension and is your server set to handle php?

Err maybe a stupid question, but did you install a local server as apache?

This isn't going to be a problem with FireFox or any other browser you might use. If the PHP isn't working it's a server issue.

Are you running this script on a webserver or are you just opening the file in FireFox? If you're just opening the file it isn't going to work.

The problem will be nothing to do with Firefox. Do a view page source and see if you have any output. Also think about getting Firebug and Live http headers to see what is going on.

Most likely, you haven't installed php on the server yet. Unlike JavaScript and HTML, php is interpreted at the server, and that requires

  1. a webserver (like apache)
  2. a php runtime
  3. php to be configured

The documentation's installation chapter explains how to install php. There are also third-party distributions like XAMPP that try to simplify the installation process.

In the comment you have the problem. You cannot access the file directly.

Start the webserver and run the file "http://localhost/file.php" then the file should work.