search

Home  >  Q&A  >  body text

Why does bool data appear when directly using the var_dump() function to output data forced by settype()?

<?php

$a=100.84;

settype($a,'int');

var_dump($a);

//This will display int (100)

?>

<?php

$a=100.84;

var_dump(settype ($a,'int'));

//This will display bool(true)

?>


城南花已开城南花已开2183 days ago1414

reply all(2)I'll reply

  • 小明

    小明2018-12-05 19:41:44

    settype has a return value, and if the set type conversion is successful, it returns true. Otherwise, it returns false

    reply
    0
  • 城南花已开

    Yes, I found out that because of the settype function structure bool settype (mixed var, string type), it will only return the *** value.

    城南花已开 · 2018-12-05 19:58:05
  • Cancelreply