I just had some very strange behavior with a simple php script I was writing. I reduced it to the minimum necessary to recreate the bug:
Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Friday, June 1, 2012
Strange behaviour after loop by reference - Is this a PHP bug?
Tuesday, May 29, 2012
Breaking out of nested loops in Java
I've got a nested loop construct like this:
for (Type type : types) {
for (Type t : types2) {
if (some condition) {
// Do something and break...
break; // Breaks out of the inner loop
}
}
}
Sunday, May 27, 2012
Why does this go into an infinite loop?
I'm a teacher, and yesterday a student wrote the following code:
Wednesday, May 23, 2012
How is an array in a PHP foreach loop read?
We have all heard of how in a for loop, we should do this:
Thursday, April 19, 2012
Is PHP"s include resource-expensive (particularly during iterations)?
Does PHP cache include requests? I was wondering how to clean up my code and I thought about using a bit more includes . Consider the following scheme.
break; vs continue; vs return;
I downloaded a free newsletter written in php from hotscripts.com
I updated a little the code to add new functionality and I saw something I don't understand.
Saturday, February 25, 2012
Filereader null declarations and appending best practice
I want to optimise my file reader function but am not sure if it is best practice to declare the nulls outside of the try loop. Also, is looping and appending chars to a Stringbuffer considered bad practice? I would like to use the exception handling here, but maybe it is better to use another structure? any advice most welcome, thanks.
I wrote a "Rock, Paper, Scissor, Shoot” game in one method using Java. I need help looping the program
I am able to loop the program, but each time I input a value it will return 2 values, the user winning and the user losing. I've experimented using multiple methods and creating a new class which was the tester, but had some problems figuring out the logic. As for loops, I have tried using a for loop, while, and do while.
Tuesday, February 14, 2012
Multiple variables access through foreach in php
foreach ($courses as $course, $sections as $section, $example as $example)
Sunday, January 29, 2012
For loop while parsing xml in php?
I am trying to create a for loop that will parse out different elements of xml doc using php. It parses when I put the number of the entry in the line: