[mapserver-users] Question about PHP object comparison

Cristiano Sumariva sumariva at gmail.com
Fri Apr 9 09:46:11 EDT 2010


I executed this example and object comparison returned true on clone call.
But it returned false when I request another reference from same layer from
getLayer.
Should not it return true ?


#/* 09/04/2010 test for mapserver object comparison on PHP.
# If I clone a layer object from a map instance and compare the cloned with
ref, do they are the same ?
# Answer: yes.
# PHP state: Two object instances are equal if they have the same attributes
and values, and are instances of the same class
#require_once dirname( __FILE__ ).'/class/mapfile/Mapfile.php';
#Mapfile::checkLibrary();

$map = ms_newMapObj( '' );
var_dump( $map->numlayers );
$l = ms_newlayerobj( $map );
var_dump( $map->numlayers );
print( nl2br( "\n" ) );
$l->set( 'type', MS_LAYER_POLYGON );
#var_dump( $l->type );
$lClone = clone $l;
var_dump( __LINE__, ( $l == $lClone ) );
var_dump( __LINE__, ( $l == $map->getLayer( 0 ) ) );
$lRef = $map->getLayer( 0 );
var_dump( __LINE__, ( $l == $lRef ), $l->type, $lRef->type );

#repeated test but now with $l from the reference from getLayer
print( nl2br( "\n" ) );
$l = $map->getLayer( 0 );
$lClone = clone $l;
var_dump( __LINE__, ( $l == $lClone ) );
var_dump( __LINE__, ( $l == $map->getLayer( 0 ) ) );
$lRef = $map->getLayer( 0 );
var_dump( __LINE__, ( $l == $lRef ), $l->type, $lRef->type );

exit;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100409/674cd74a/attachment.html


More information about the mapserver-users mailing list