"Fossies" - the Fresh Open Source Software Archive

Member "hhvm-HHVM-4.166.0/hphp/test/zend/good/ext/standard/tests/general_functions/001.php" (8 Aug 2022, 1138 Bytes) of package /linux/www/hhvm-HHVM-4.166.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?hh
    2 <<__EntryPoint>> function main(): void {
    3 $agent = sprintf("%.5s", "James Bond, 007");
    4 
    5 echo("sprintf string truncate test:   ");
    6 if ($agent == "James") {
    7     echo("passed\n");
    8 } else {
    9     echo("failed!\n");
   10 }
   11 
   12 echo("sprintf padding and align test: ");
   13 $test = sprintf("abc%04d %-20s%c", 20, "fisketur", 33);
   14 if ($test == "abc0020 fisketur            !") {
   15     echo("passed\n");
   16 } else {
   17     echo("failed!\n");
   18 }
   19 
   20 echo("sprintf octal and hex test:     ");
   21 $test = sprintf("%4o %4x %4X %0"."8x", 128, 1024, 49151, 3457925);
   22 if ($test == " 200  400 BFFF 0034c385") {
   23     echo("passed\n");
   24 } else {
   25     echo("failed!\n");
   26 }
   27 
   28 echo("sprintf octal binary test:      ");
   29 $test = sprintf("%b", 3457925);
   30 if ($test == "1101001100001110000101") {
   31     echo("passed\n");
   32 } else {
   33     echo("failed!\n");
   34 }
   35 
   36 echo("sprintf float test:             ");
   37 $test = sprintf("%0"."06.2f", 10000/3.0);
   38 if ($test == "3333.33") {
   39     echo("passed\n");
   40 } else {
   41     echo("failed!\n");
   42 }
   43 
   44 echo sprintf("%.2f\n", "99.00");
   45 echo sprintf("%.2f\n", 99.00);
   46 
   47 echo sprintf("%e\n", 1.234E-18);
   48 echo sprintf("%e\n", 1.234E+18);
   49 echo sprintf("%e\n", 9843243.12);
   50 echo sprintf("%e\n", -9843243.12);
   51 }