EDIT: In an effort to make this question not totally useless I'm changing the subject.
Why does PHP not throw an error when you have a typo like contninue; in the code when error reporting is set to E_STRICT.
See my below original question. I was trying to continue a foreach loop, but accidentally wrote contninue; instead of continue;, yet I received no warning or error from either NetBeans IDE or PHP when the script was run. I have E_STRICT and E_ALL error reporting on, HTML errors on, display errors on, etc. Is there any way to make programming in PHP more bullet-proof to these kinds of stupid errors? Note that there was no variable or function named contninue. In fact, I can type pretty much anything in a line including dsafdsfdafdsafdsafdsafdsa_FDA9812324398s; and it will not throw an error.
Original question: Why doesn't continue in PHP for each loop skip to the next loop?
It's a bit embarassing to post a question like this but here goes...
Here's a little snippet of code from a function. I'm simply trying to recreate an array filtering out one or more items in the array that meet certain criteria, in this case match a postId. (This is development in Wordpress in case you're wondering.)
In my simple foreach loop, the continue; command doesn't appear to be doing its job. At least its not behaving how I would expect from any other language I've used (C, C#, MEL, Javascript, etc.) The echoed output always includes "should have exited but it did not!" even though its after the continue; and should never be executed. Also, the resulting array always contains the filtered content even though "REMOVED " . $postId clearly ran.
$posts = get_posts( $args ); // posts is an array of objects
if($posts == null) return; // no posts
if($includeCurrentPost || $postId < 0) return $posts; // we are including all posts, so just return it
// Remove current post id from list since excluding
$newPosts = array();
$count = 0;
foreach($posts as $p) {
if($p->ID == $postId) {
echo("REMOVED " . $postId);
contninue;
echo("should have exited but it did not!");
}
$newPosts[$count++] = $p;
}
return $newPosts;
Okay, I normally program in C# and consider myself a decent mid-level programmer. This just doesn't make any sense. @_@ I'm guessing its going to turn out to be some stupid syntax error that PHP is just letting me get away with that I can't see...
PHP version it 5.3 something, Apache, running on Windows Vista.