Procházet zdrojové kódy

Update PHP URL generation example (#66)

String interpolation is a little easier to read and understand as there's no back-and-forth between string format and arguments. 

Matches JS version: https://github.com/DarthSim/imgproxy/blob/master/examples/signature.js#L27
Adam Quaile před 6 roky
rodič
revize
09bfd44c55
1 změnil soubory, kde provedl 2 přidání a 2 odebrání
  1. 2 2
      examples/signature.php

+ 2 - 2
examples/signature.php

@@ -23,8 +23,8 @@ $extension = 'png';
 $url = 'http://img.example.com/pretty/image.jpg';
 $encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
 
-$path = sprintf("/%s/%d/%d/%s/%d/%s.%s", $resize, $width, $height, $gravity, $enlarge, $encodedUrl, $extension);
+$path = "/{$resize}/{$width}/{$height}/{$gravity}/{$enlarge}/{$encodedUrl}.{$extension}";
 
 $signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin.$path, $keyBin, true)), '+/', '-_'), '=');
 
-print(sprintf("/%s%s", $signature, $path));
+print(sprintf("/%s%s", $signature, $path));