PageRenderTime 38ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/standard/tests/general_functions/uniqid_basic.php

http://github.com/facebook/hiphop-php
PHP | 34 lines | 25 code | 4 blank | 5 comment | 1 complexity | 0cb90262dc138cca28cf2bc67fc5576c MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. /* Prototype : string uniqid ([ string $prefix= "" [, bool $more_entropy= false ]] )
  3. * Description: Gets a prefixed unique identifier based on the current time in microseconds.
  4. * Source code: ext/standard/uniqid.c
  5. */
  6. <<__EntryPoint>> function main(): void {
  7. echo "*** Testing uniqid() : basic functionality ***\n";
  8. echo "\nuniqid() without a prefix\n";
  9. var_dump(uniqid());
  10. var_dump(uniqid('', true));
  11. var_dump(uniqid('', false));
  12. echo "\n\n";
  13. echo "uniqid() with a prefix\n";
  14. // Use a fixed prefix so we can ensure length of o/p id is fixed
  15. $prefix = varray [
  16. 99999,
  17. "99999",
  18. 10.5e2,
  19. null,
  20. true,
  21. false
  22. ];
  23. for ($i = 0; $i < count($prefix); $i++) {
  24. var_dump(uniqid((string)$prefix[$i]));
  25. var_dump(uniqid((string)$prefix[$i], true));
  26. var_dump(uniqid((string)$prefix[$i], false));
  27. echo "\n";
  28. }
  29. echo "===DONE===\n";
  30. }