0

I'm sure I'm missing something very obvious here. I create the below php file and loaded it in xampp with apache running. I would expect it to print 'hello' 5 times. Instead the page is blank, and the if I inspect the page elements in chrome, I see the PHP as commented out, as shown in the below image.

<?
for($i = 0; $i < 5; $i++) {
    echo 'hello';
}
?>

enter image description here

Lal
  • 14,893
  • 4
  • 41
  • 68
ab11
  • 19,320
  • 39
  • 109
  • 199

3 Answers3

1

Replace your code as

<?php
for($i = 0; $i < 5; $i++) {
    echo 'hello';
}
?>

If you are using short tags, then it must be configured in your config file. Too set short tags add

short_open_tag=On

in php.ini

And restart your Apache server.

Lal
  • 14,893
  • 4
  • 41
  • 68
  • thanks, the typo was actually just in typing it into SO. issue was the opening tag. didn't realize I couldn't use short tags. thanks – ab11 Jun 21 '15 at 17:07
0

Firstly, use the <?php opening tag. <? may have been disabled.

Secondly, syntax error in your for loop. You're missing a $ for i++.

light
  • 3,958
  • 2
  • 23
  • 37
0

you missed $ in for loop its $i not i
the correct one is shown below...hope this solves

for($i = 0; $i < 5; $i++) { <br>
    echo 'hello'; <br>
} 
Hanky Panky
  • 45,969
  • 8
  • 69
  • 95
Unni Babu
  • 1,819
  • 11
  • 16