Sophie

Sophie

distrib > Mandriva > cooker > x86_64 > by-pkgid > 696ab6d939cc7bb56b651a0a3a4eaf41 > files > 7

php-shp-0.9.2-14.x86_64.rpm

--TEST--
Testing shp_read_object()  shp_rewind_object()  shp_destroy_object()
--FILE--
<?php 
error_reporting(E_ALL & ~E_STRICT);
if (!extension_loaded('shp')) dl('shp.so');


echo "Opening again for reading: ";
$shph = shp_open("/tmp/lakes.shp", "rb");
var_dump($shph);

echo "Reading object 0: ";
$shp_obj = shp_read_object($shph, 0);
var_dump($shp_obj);

echo "Destroying object 0: ";
$res = shp_destroy_object($shp_obj);
var_dump($res);

echo "Reading object 999999: ";
$shp_obj2 = shp_read_object($shph, 999999);
var_dump($shp_obj2);

echo "Extracting object 2 and rewinding: ";
$shp_obj = shp_read_object($shph, 2);
var_dump($shp_obj);
$res = shp_rewind_object($shph, $shp_obj);
var_dump($res);
echo "Now writing at the end (should generate an error because read only mode): ";
$res = shp_write_object($shph, -1, $shp_obj);
var_dump($res);
shp_close($shph);

echo "\n-END-\n";
?>
--EXPECTF--
Opening again for reading: resource(%d) of type (SHP Handle)
Reading object 0: resource(%d) of type (SHP Object)
Destroying object 0: bool(true)
Reading object 999999: 
Warning: shp_read_object(): Reading of object 999999 failed in %s on line %d
NULL
Extracting object 2 and rewinding: resource(%d) of type (SHP Object)
bool(false)
Now writing at the end (should generate an error because read only mode): Error in fseek() or fwrite().
int(-1)

-END-