PHP 8.5.0 Alpha 4 available for testing

Voting

: max(six, five)?
(Example: nine)

The Note You're Voting On

taylorsarrafian at gmail dot com
10 years ago
beware:

<?php

// observe the following
echo intval( strval( -0.0001 ) ); // 0
echo intval( strval( -0.00001 ) ); // -1

// this is because
echo strval( -0.0001 ); // -.0001
echo strval( -0.00001 ); // -1.0E-5

// thus beware when using
function trunc2_bad( $n ) {
return
intval( strval( $n * 100 ) / 100 );
}

// use this instead
function trunc2_good( $n ) {
return
intval( floatval( strval( $n * 100 ) ) / 100 );
}

?>

<< Back to user notes page

To Top