PHP/Variables: Difference between revisions
wikademia>Senthryl rv v |
wikademia>MichaelBillington m →Variable conversion: moving stuff around to prevent exceptionally long lines |
||
| Line 22: | Line 22: | ||
<?php | <?php | ||
$input = '4string2'; | $input = '4string2'; | ||
// Should multiply 42 by pi, but will probably post a warning or terminate the script with an error | |||
$thevalue = $input * pi(); | |||
// This should return 0 or false, not print anything or even return an error for the previous line | |||
echo $thevalue; | |||
?> | ?> | ||
As '4string2' is not a number, PHP will fail to convert it (in order to be multiplied by pi(), which returns a floating point value) and (most likely) return an error or post a warning (depending on PHP's configuration settings in the php.ini file). | As '4string2' is not a number, PHP will fail to convert it (in order to be multiplied by pi(), which returns a floating point value) and (most likely) return an error or post a warning (depending on PHP's configuration settings in the php.ini file). | ||
== Variable types == | == Variable types == | ||