note 123680 added to language.types.type-juggling

From: Date: Mon, 11 Mar 2019 17:16:00 +0000
Subject: note 123680 added to language.types.type-juggling
Groups: php.notes 
Request: Send a blank email to php-notes+get-210354@lists.php.net to get a copy of this message
"An example of PHP's automatic type conversion is the multiplication operator '*'. If either operand is a float, then both operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does not change the types of the operands themselves; the only change is in how the operands are evaluated and what the type of the expression itself is." I understand what the doc is trying to say here, but this sentence is not correct as stated, other types can be coerced into floats. e.g. <?php $a = "1.5"; // $a is a string $b = 100; // $b is an int $c = $a * $b; // $c is a float, value is 150 // multiplication resulted in a float despite fact that neither operand was a float ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.34 (proxied: 107.1.251.186) ---- Manual Page -- http://php.net/manual/en/language.types.type-juggling.php Edit -- https://master.php.net/note/edit/123680 Del: integrated -- https://master.php.net/note/delete/123680/integrated Del: useless -- https://master.php.net/note/delete/123680/useless Del: bad code -- https://master.php.net/note/delete/123680/bad+code Del: spam -- https://master.php.net/note/delete/123680/spam Del: non-english -- https://master.php.net/note/delete/123680/non-english Del: in docs -- https://master.php.net/note/delete/123680/in+docs Del: other reasons-- https://master.php.net/note/delete/123680 Reject -- https://master.php.net/note/reject/123680 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#210354) next »