Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

Product with assignment (*=)

Scale the stored value by the factor on the right.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

$value *= $operand

Scale the stored value by the factor on the right. Multiplying by 2 twice gives four times the initial value.

With integer operands a result within the integer range stays an integer. Overflow can produce a float and lose precision.

Evaluation

  • $value = 16; $value *= 5; → 80
  • $value = (-4); $value *= 3; → -12
  • $value = 9; $value *= 0; → 0

Examples

<?php
$value = 16;
$value *= 5;
echo json_encode($value), PHP_EOL;

$value = (-4);
$value *= 3;
echo json_encode($value), PHP_EOL;

$value = 9;
$value *= 0;
echo json_encode($value), PHP_EOL;

Result

80
-12
0

Sources