0

I am trying to create a php loop as follows:

<?php
for ($i= 0; $i < 18; $i++)
{
echo "hello World";
echo "</br>";
} 
?>

when I run it I get this as an output:

"; } ?>

However when I used http://www.writephponline.com/ I get the expected output.

I'm using notepad++ and chrome. The file has a .php ext.

Is there something missing?

Surely it is a silly mistake but can't figure it out. I appreciate your help.

Frank Fajardo
  • 7,034
  • 1
  • 29
  • 47
Feras
  • 75
  • 9

3 Answers3

0

You need to be running a web server with php installed. You appear to be loading the file directly from a server with no php installed, or as a file directly, without a server. Your file is being interpreted as HTML not PHP

RichGoldMD
  • 1,252
  • 1
  • 10
  • 18
0

you are missing the php interpreter.... As you are using windows, you can take a look to WAMP to setup a working php enviroment http://www.wampserver.com/en/

Simonluca Landi
  • 931
  • 8
  • 21
0

browser can't run your php code.

here is a way that you could run your php code :

 1. open terminal  
 2. go to the directory where your file exist
 3. type this command "php -S localhost:8000"

now open your browser and goto http://localhost:8000/YOUR_FILE_NAME.php" or just http://localhost:8000/ if the file name is index.php

NOTE : you should have php installed in your computer

Ali Faris
  • 17,754
  • 10
  • 45
  • 70