note 127115 added to language.operators.arithmetic

From: Date: Thu, 19 May 2022 11:46:43 +0000
Subject: note 127115 added to language.operators.arithmetic
Groups: php.notes 
Request: Send a blank email to php-notes+get-218493@lists.php.net to get a copy of this message
With PHP 8.1 and more, be carefull to the modulo "%" Both argument must be some integer or a float without floating part. Bad Example: <?php 12.5 % 4.5 ?> You will enjoy a : Deprecated: Implicit conversion from float 12.5 to int loses precision in ... filename Deprecated: Implicit conversion from float 5.4 to int loses precision in ... filename A fix, cast your int : <?php (int) 12.5 % (int)4.5 ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.47 (proxied: 87.98.137.70) ---- Manual Page -- https://php.net/manual/en/language.operators.arithmetic.php Edit -- https://main.php.net/note/edit/127115 Del: integrated -- https://main.php.net/note/delete/127115/integrated Del: useless -- https://main.php.net/note/delete/127115/useless Del: bad code -- https://main.php.net/note/delete/127115/bad+code Del: spam -- https://main.php.net/note/delete/127115/spam Del: non-english -- https://main.php.net/note/delete/127115/non-english Del: in docs -- https://main.php.net/note/delete/127115/in+docs Del: other reasons-- https://main.php.net/note/delete/127115 Reject -- https://main.php.net/note/reject/127115 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218493) next »