To complete the francis' answer, it is valid to put the C source code of the PHP implementation. For example, when using the function settype, the documentation recommends:
Possible values for type are:
- "float" (only for versions above PHP 4.2.0, for older versions use the deprecated variation "double")
That is, you will need to define how float instead of double, but checking the implementation of the function, we have:
/* {{{ proto bool settype(mixed &var, string type)
Set the type of the variable */
PHP_FUNCTION(settype)
{
zval *var;
char *type;
size_t type_len = 0;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL_DEREF(var)
Z_PARAM_STRING(type, type_len)
ZEND_PARSE_PARAMETERS_END();
if (!strcasecmp(type, "integer")) {
convert_to_long(var);
} else if (!strcasecmp(type, "int")) {
convert_to_long(var);
} else if (!strcasecmp(type, "float")) {
convert_to_double(var);
} else if (!strcasecmp(type, "double")) { /* deprecated */
convert_to_double(var);
} else if (!strcasecmp(type, "string")) {
convert_to_string(var);
} else if (!strcasecmp(type, "array")) {
convert_to_array(var);
} else if (!strcasecmp(type, "object")) {
convert_to_object(var);
} else if (!strcasecmp(type, "bool")) {
convert_to_boolean(var);
} else if (!strcasecmp(type, "boolean")) {
convert_to_boolean(var);
} else if (!strcasecmp(type, "null")) {
convert_to_null(var);
} else if (!strcasecmp(type, "resource")) {
php_error_docref(NULL, E_WARNING, "Cannot convert to resource type");
RETURN_FALSE;
} else {
php_error_docref(NULL, E_WARNING, "Invalid type");
RETURN_FALSE;
}
RETVAL_TRUE;
}
/* }}} */
Where the lines stand out:
} else if (!strcasecmp(type, "float")) {
convert_to_double(var);
}
If the guy is float, converts the value to double. And the type defined as double was rendered obsolete for who knows why (searching for information in the changelog).
The same occurs with the function floatval:
/* {{{ proto float floatval(mixed var)
Get the float value of a variable */
PHP_FUNCTION(floatval)
{
zval *num;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(num)
ZEND_PARSE_PARAMETERS_END();
RETURN_DOUBLE(zval_get_double(num));
}
/* }}} */
Returning the very type double.
The full source file can be seen on official language repository.
There’s really no difference in all three. Related issue in Soen
– Isac
Forgot the question or haven’t found the answer you wanted? hahaha
– Francisco