Oddities

From MapbenderWiki

Jump to: navigation, search

Contents

__toString() faulty in PHP < 5.2

$bbox = new Mapbender_bbox($minx, $miny, $maxx, $maxy, $epsg)
$e = new mb_exception("bbox is " . $bbox);

returns the following in PHP < 5.2

bbox is Object Id #xy

in PHP >= 5.2 something like

bbox is [1234,1234,3245,2345,EPSG:34253]

but if called directly via echo, it works even in < 5.2

echo $bbox;

results in the desired output

bbox is [1234,1234,3245,2345,EPSG:34253]

SimpleXML->children() behaves different in PHP 5.0.4 and 5.2

if a SimpleXMLElement contains multiple siblings, children() returns

  • all children of the first sibling in 5.0.4
  • all siblings in 5.2

You can avoid this by switching between DOM and SimpleXML by using these functions

  • simplexml_import_dom(DOMNode)
  • dom_import_simplexml(SimpleXMLElement)

HTML forms: submit() doesn't execute code mentioned in onsubmit=''

The one important difference between the submit() method and form submission 
by the user is that the onsubmit() event handler is not invoked when submit() 
is called. If you use onsubmit() to perform input validation, for example, 
you'll have to do that validation explicitly before calling submit().

It is more common to use a Submit button to allow the user to submit the form 
than it is to call the submit() method yourself.

parent.$.toJSON() faulty

the typeof operator cannot determine the correct type of arrays in iframes.

This results in faulty detection of arrays as objects.

Instead of

[1,2,3]

you get

{"0":1, "1":2, "2":3}

Avoid iframes or load jQuery and jqson in the the iframe as well.

Views
Personal tools