OT - Bizarre PHP problem/bug

Michael Torrie torriem at gmail.com
Mon Nov 22 17:20:32 MST 2010


On 11/22/2010 05:16 PM, William Attwood wrote:
> There is no code, attached.  It's an empty file.  That could explain it.

Would indeed.  Apparent .php is a dangerous attachment.  Here's the
code.  Basically I found the problem.  PHP is trying to cast my string
as a number, and so any string is always equal to zero.  Brilliant.  PHP
rocks!

$p= Array
                (
                    "expid" => "Experiment Blah",
                    "date" => "Fall 2010",
                    0 => Array
                        (
                            "unknown" => "SO3",
                            "num_samples" => 0
                        )
                );

foreach ($p as $k=>$v) {
        print("$k: $v\n");
        if($k == "expid") {
                print("$k is expid\n");
        }
}

if (0 == "hi") {
        print "Somehow 0 == hi\n";
}





More information about the PLUG mailing list