WebsiteBaker 2.13.8 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
do you have some more sections on this special page?
Wed, 23 Oct 2024 15:19:14 +0000 [E_DEPRECATED] /modules/minislides/functions.php:[170] from /modules/minislides/functions.php:[170] imagecopyresampled "Implicit conversion from float 843.75 to int loses precision""
PHP is a dynamically typed language. As such, there are many cases where type coercion occurs naturally. Most of these coercions are harmless and super-practical.However, when a float number is converted to an integer, this is often associated with data loss. For example, if the float number 3.14 is converted to an integer number 3, it loses its decimal value.The same happens if the float is outside the platform integer range, or if a float string is converted to an integer.PHP 8.1 corrects this behavior and brings dynamic type coercion more in line with most modern programming languages. The goal is to make such constraints predictable and intuitive.In PHP 8.1, you will see a deprecation note when a non-compatible float is implicitly converted to an int. But what is an integer-compatible float? The RFC answers this:A float is said to be integer-compatible if it has the following properties: Is a number (i.e. not NaN or Infinity) Is in the range of a PHP integer (platform-dependent) Does not have a decimal partThis hint will be converted to a TypeError in the next PHP version (i.e. PHP 9.0).
$crop_h = $orig_h*($size/$orig_w);
$crop_h = intval($orig_h*($size/$orig_w));
ImageCopyResampled($result, $image, 0, 0, $x, $y, $size[0], $size[1], $width, $height);
PHP ist eine dynamisch typisierte Sprache. Als solche gibt es viele Fälle, in denen Typenzwang natürlich vorkommt. Die meisten dieser Zwänge sind harmlos und superpraktisch.Wenn jedoch eine Float-Zahl in eine Integer-Zahl umgewandelt wird, ist dies oft mit Datenverlust verbunden. Wenn zum Beispiel die Float-Zahl 3,14 in eine Integer-Zahl 3 umgewandelt wird, verliert sie ihren Nachkommawert.Das Gleiche passiert, wenn der Float außerhalb des Plattform-Integer-Bereichs liegt, oder wenn ein Float-String in einen Integer konvertiert wird.PHP 8.1 korrigiert dieses Verhalten und bringt die dynamische Typenzwangssteuerun g mehr in Einklang mit den meisten modernen Programmiersprachen . Das Ziel ist es, solche Zwänge vorhersehbar und intuitiv zu machen.In PHP 8.1 wirst du eine Deprecation-Notiz sehen, wenn ein nicht kompatibler Float implizit in einen Int umgewandelt wird. Aber was ist ein integer-kompatibler Float? Der RFC beantwortet dies:Ein Float wird als integer-kompatibel bezeichnet, wenn er die folgenden Eigenschaften besitzt: Ist eine Zahl (d.h. nicht NaN oder Infinity) Liegt im Bereich eines PHP Integers (plattformabhängig) Hat keinen NachkommaanteilDieser Hinweis wird in der nächsten PHP Version (d.h. PHP 9.0) in einen TypeError umgewandelt.
ImageCopyResampled($result, $image, 0, 0, intval($x), intval($y), intval($size[0]), intval($size[1]), intval($width), intval($height));
And whether the code becomes more readable with lots of intval calls is something I'll leave open
Und ober der Code mit vielen intval-Aufrufen lesbarer wird, lasse ich mal offen