http://www.osoft.com/store/products/osoft_1490922690php-logo.png

I’m a programmer and I’ve written a few compilers, but maybe my expectations are too high? Here is some PHP code that doesn’t work. But if you report it as a bug as I did they say, “that’s how it’s supposed to work”. I think they think if you document a bug it’s not a bug any more. This is what gives open source a bad name… lack of responsibility.

Here’s the code. Pretty simple stuff

$myarray = array("one","two","three","four");

foreach ($myarray as &$x) {
   $x = "$x -";
   print "$x\n";
}

print "\n";

foreach ($myarray as $x) {
   print "$x\n";
}

You would expect it to print this:

one -
two -
three -
four -
one -
two -
three -
four -

Actual result:

one -
two -
three -
four -

one -
two -
three -
three -

As you can see – not what a reasonable person would expect. Not only am I shocked that PHP fails this simple example, but when I went to report it the response is “that’s not a bug – it’s supposed to do that”. It supports my claim that the VI editor causes brain damage.




  1. 1894 says:

    Hey #6, I went to that link you provided and I nearly fainted. I could read the page so easily, see the links perfectly, and it made me wonder why the whole internet isn’t done in the fancy PHP stuff.

    I guess my shock is a bit exaggerated but the point is I’m so sick of going to websites in poofy light blue and light grey and light green and light pink, so light I can’t even see it if I put on a reading light.

    I mean, who are these IDIOTS that make pages like that. I mean, it’s not 1984.

  2. qb says:

    #14 You’re using a Type 1 JDBC driver to hit a MS Access database? What’s next, Spock with a beard?

  3. jccalhoun says:

    I’m no programmer so I may be totally wrong here. However, given the comments here especially number 20, this seems to be starting to smell like another “forever stamp” post http://dvorak.org/blog/2009/02/01/forever-stamp-not-forever-at-san-francisco-post-office/ where Marc Perkel is proven to be wrong and refuses to admit it.

  4. amodedoma says:

    Go ahead try an Ubuntu installation, give open source a chance. I’m sure once you’ve used some decent software that doesn’t require buying or pirating anything, you’ll be hooked. Oh and if you think you’ll get better technical assistance just because your paying, better think again. In fact I’ve used developer software from maybe a dozen sources and I usually find the help I need on the net in the blogs etc. Who has time to wait on hold for some guy with a funny accent from some far away nation to help you? – If you know how to use a search engine – it’s better and faster than customer support and technical assistance combined. Right now I’m using chromium browser (google’s opensource) and it’s amazingly efficient on system resources. If it’s any indication I’d say Chrome OS is gonna be a big hit.

  5. hhh says:

    Marc,

    please admit you’re wrong.

    this way we can stop talking about it already.

  6. Mike Yuen says:

    All languages have this kind of odd ‘feature’… its not really an open source specific situation. Most of what you spend time doing as a programmer is learning about these things. Then learning that all the computer and language are doing is what you told them to….

    A case of “do what i want you to do not what i told you to do”.

  7. kelphis says:

    I would hope that adding a print_r() in the second loop will show why this is not a bug. You can actually see that $x is still a referenced variable and that the array is being modified as the loop is iterated. So upon each iteration $x is being assigned the next element in $myarray.

    2 things to avoid this behavior is to unset($x) after the first loop or use a different variable in the second loop. Each one will work, but I think that the first option would work best considering you seem to expect this behavior to happen anyways. You are basically complaining the php doesn’t know what you are trying to do with a variable that you are using in to different places within the same scope.

  8. PhP Programmer says:

    PHP is a tool that allows your website to have functionalities for business purposes. If you want to improve and upgrade, you can always get the services of a PHP programmer.



Bad Behavior has blocked 25398 access attempts in the last 7 days.