Jump to content
View in the app

A better way to browse. Learn more.

The Uniform Server Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

echo not working locally

Featured Replies

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

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 :)

  • Author

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

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 :)

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...

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.