Search code examples
phpsyntaxnumbers

PHP number thousand separator in syntax


My code has some long constant numbers. To avoid mistakes, I want to declare numbers with thousand separators. In Java 7, I can do this:

int MyConst = 1_000_000;   ///The token '_' (thousand separator) make it more clearance

How can I do that in PHP?


Solution

  • PHP does not offer such feature. See: http://www.php.net/manual/en/language.types.integer.php

    You could use scientific notation to represent big numbers: http://www.php.net/manual/en/language.types.float.php but then again, your integers would be actually floats and you'd probably have to add typecasting.