# Why won't my code work?? It keeps telling me i have an error!

and it keeps telling me "Oops, try again. Your first call to round() should print an integer."

Heres the code:
<?php
// Try rounding a floating point number to an integer
// and print it to the screen
\$round = round(M_PI);
print \$round;
?>

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
\$rounddecimal = round(MPI,3);
print \$round_decimal;
?>

Nevermind.. I looked at another answer on the forum and it was right... everything i tried wasnt working

<?php
// Try rounding a floating point number to an integer
// and print it to the screen
\$test = round(3.4);
echo \$test;
?>

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
\$test = round(3.4312,3);
echo \$test;
?>

##### 1 Comment

Ng Jia Juin almost 4 years ago

Oh, I got it! Thanks!

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
\$rounddecimal = round(MPI,3);
print \$round_decimal;
?>

this if my correct code.
\$rounddecimal = round(M_PI,3);
print \$rounddecimal;

<?php
// Try rounding a floating point number to an integer
// and print it to the screen
\$test = round(3.4);
echo \$test;
?>

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
\$test = round(3.4312,3);
echo \$test;
?>

copy paste this if u have a problem

<?php
// Try rounding a floating point number to an integer
// and print it to the screen
\$round = round(MPI);
print \$round;
?>

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
\$round
decimal = round(MPI, 3);
print \$round
decimal;
?>

.................................................

##### 1 Comment

thefracture over 3 years ago

add underscore between M and PI LIKEKE THIS M_PI