Type casting - chung-leong/qb GitHub Wiki

The regular type-casting syntax does not work in PHP+QB, as the QB primitive types are not PHP keywords. To cast a value to a specific type, use the type($expr) syntax instead.

Example:

<?php

/**
 * @engine qb
 * @local float64 $a
 */
function test_function() {
	$a = 1234.5678;
	echo uint32($a), "\n";
	echo uint8($a), "\n";
}

qb_compile();
test_function();

?>

Result:

1234
210

In the example above, casting the float64 number to uint32 leads to the loss of the fractional part. Casting to uint8 leads to an integer overflow, reducing the value to 1234 % 256 = 210.