Jump to content
The Uniform Server Community
Shelly300

echo not working locally

Recommended Posts

I hope I am in the correct section for this request. A search on discussion threads using 'echo not working' (and variations of) yielded nothing that can help me.

I have been having some trouble with some complex php pages. Just in case I was over complicating things I decided to go back to basics and do some beginners tutorials and found a very annoying problem: echo is not working locally.

The tutorial starts with a simple helloworld.php page and when run locally there is no 'Hello World' displayed on the page. However, when the page is uploaded to a host server the echo works just fine and 'Hello World' is displayed. Therefore I know there is nothing wrong with the file.

I have my Uniform Server installed with defaults and have been using it successfully without a drama from the get-go... until now.

Firefox will give me a blank page without the echo displayed; IE7 displays the page as text (showing html tags); and Chrome downloads the page to be opened as a text file.

Notepad is my default when opening php and inc files.

Please could someone tell me what settings need to be changed in my local server to rectify this.

 

Thank you

Share this post


Link to post
Share on other sites

I cannot explain your observations, there are no special settings to get echo to function.

Can you post your code? I would like to see if it’s reproducible on my set-up.

 

All the best

Ric :)

Share this post


Link to post
Share on other sites

Thank you for your reply Ric

 

this simple code is the contents of a file called helloworld.php

 

<html>

<head>

<title>My First PHP Page</title>

</head>

<body>

<?php

echo "Hello World!";

?>

</body>

</html>

 

Thanks

Share this post


Link to post
Share on other sites

There is nothing wrong with your code it should run with no problems.

 

The three browsers are doing something different suggesting that the page is not being processed by PHP! They are treating the page as a standard file, are you directly opening the file from your browsers because that would explain your observations.

 

If your browser address bar is displaying something like file:///W/test.php

Then you opened it directly bypassing the server.

 

If you typed in http://localhost/test.php a browser is expecting the page to be served.

 

Trouble is you have had the server working “and have been using it successfully without a drama” hence the above is clearly not the problem.

 

I can’t think of anything else to explain the different browser responses.

 

All the best

Ric :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...