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,726
  • 4
  • 45
  • 70
ab11
  • 19,770
  • 42
  • 120
  • 207

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,726
  • 4
  • 45
  • 70
  • 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
  • 4,157
  • 3
  • 25
  • 38
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
  • 46,730
  • 8
  • 72
  • 95
Unni Babu
  • 1,839
  • 12
  • 16