Skip to content
Advertisement

Does PHP scanf behave differently with %f versus %lf?

Are these two lines equivalent? Is one recommended over the other? How about %d and %ld?

fscanf( $f, "%f", $value );
fscanf( $f, "%lf", $value );

Advertisement

Answer

If I read their source code right, the l modifier is simply ignored, so there shouldn’t be any difference, and the recommended version should be without the l, which is also not found in the official documentation.

Modifiers are also ignored in sprintf.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement