summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--redis.php3
-rw-r--r--zstd.php17
2 files changed, 13 insertions, 7 deletions
diff --git a/redis.php b/redis.php
index aacc581..7c42d0b 100644
--- a/redis.php
+++ b/redis.php
@@ -12,6 +12,9 @@ namespace Remi;
if (PHP_VERSION_ID < 70400 || !extension_loaded("ffi")) {
die("PHP 7.4 with ffi extension required\n");
}
+if (PHP_SAPI != "cli") {
+ Header('Content-Type: text/plain');
+}
printf("PHP version %s\n", PHP_VERSION);
if (PHP_SAPI == "cli" && !class_exists("\\Remi\\Redis")) {
printf("Fallback on manual load\n\n");
diff --git a/zstd.php b/zstd.php
index 0ec22d7..43d6d3f 100644
--- a/zstd.php
+++ b/zstd.php
@@ -12,6 +12,9 @@
if (PHP_VERSION_ID < 70400 || !extension_loaded("ffi")) {
die("PHP 7.4 with FFI required\n");
}
+if (PHP_SAPI != "cli") {
+ Header('Content-Type: text/plain');
+}
printf("PHP version %s\n", PHP_VERSION);
if (PHP_SAPI == "cli" && !class_exists("\\Remi\\Zstd")) {
@@ -27,20 +30,20 @@ if (class_exists("\\Remi\\Zstd")) {
$comp = \Remi\Zstd::compress($src);
printf("\nSrc length = %d\n", \strlen($src));
printf("ZSTD_compress = %d\n", \strlen($comp));
- file_put_contents("testffi.zstd", $comp);
+ file_put_contents("/tmp/testffi.zstd", $comp);
- $comp = file_get_contents("testffi.zstd");
+ $comp = file_get_contents("/tmp/testffi.zstd");
$out = \Remi\Zstd::decompress($comp);
printf("Src length = %d\n", \strlen($comp));
printf("ZSTD_decompress = %d\n", \strlen($out));
- file_put_contents("testffi.orig", $out);
+ file_put_contents("/tmp/testffi.orig", $out);
printf("Check = %s\n", $src === $out ? "OK" : "KO");
$t = microtime(true) - $t;
printf("Using FFI extension = %.3f\"\n\n", $t);
} else {
- printf("FFI missing\n\n");
+ printf("\\Remi\\Zstd missing\n\n");
}
if (extension_loaded("zstd")) {
@@ -53,14 +56,14 @@ if (extension_loaded("zstd")) {
$clen = strlen($comp);
printf("ZSTD_compress = %d\n", $clen);
$comp = substr($comp, 0, $clen);
- file_put_contents("testzstd.zstd", $comp);
+ file_put_contents("/tmp/testzstd.zstd", $comp);
- $comp = file_get_contents("testzstd.zstd");
+ $comp = file_get_contents("/tmp/testzstd.zstd");
printf("Src length = %d\n", \strlen($comp));
$unco = zstd_uncompress($comp);
$ulen = strlen($unco);
printf("ZSTD_decompress = %d\n", $ulen);
- file_put_contents("testzstd.orig", $unco);
+ file_put_contents("/tmp/testzstd.orig", $unco);
printf("Check = %s\n", $src === $unco ? "OK" : "KO");
$t = microtime(true) - $t;