-3

I'm learning PHP but it doesn't work. Do you guys know what's wrong with my code? http://h51116rm.informatica-laz.nl/PHP/Opdracht_182.php . This is my domain. The sentence is in Dutch so don't worry about that. The sentence in the array needs to pop up on the page.

<?php
$omwisselen = array("Peter ","is ","de ","broer ","van ","Hans ");

for ($i=0; $i<count($omwisselen); i++) {
    echo $omwisselen[$i];
}
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Ryon M
  • 81
  • 6
  • 4
    `i++` should be `$i++` Variables always have a `$` in front of them. – RiggsFolly Jan 21 '17 at 21:29
  • While testing Add [error reporting](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php/845025#845025) to the top of your file(s) _while testing_ right after your opening PHP tag for example ` – RiggsFolly Jan 21 '17 at 21:30
  • Also might help to use a syntax highlighting code editor. You might see the error right away, and not even need to post on SO. – Reisclef Jan 21 '17 at 21:31
  • Thanks, that was a stupid fault. What do you mean with that, i can't get the error code to work. – Ryon M Jan 21 '17 at 21:32
  • Yeah, i'm using notepad++, but i'm now on ubuntu and my plugin menu didn't work. – Ryon M Jan 21 '17 at 21:33

2 Answers2

1

just change i++ to $i++ and check

 <?php
 $omwisselen = array("Peter ","is ","de ","broer ","van ","Hans ");

 for ($i=0; $i<count($omwisselen); $i++) {
 echo $omwisselen[$i];
 }
 ?>
M. Alim
  • 153
  • 16
  • Nice spot, never would have [figured that one](http://stackoverflow.com/questions/41784703/whats-wrong-with-my-php-code#comment70759363_41784703) – RiggsFolly Jan 21 '17 at 21:43
0

In the for loop, you forgot $. You wrote i++ instead of $i++.

I'll suggest using netbeans.. I haven't notice that mistake to, until I pasted it in the netbeans..

Bar Shema
  • 3
  • 5
  • Nice spot, never would have [figured that one](http://stackoverflow.com/questions/41784703/whats-wrong-with-my-php-code#comment70759363_41784703) – RiggsFolly Jan 21 '17 at 21:44