summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/chr_ord.phpt
blob: be0b1a32da5430929583f56daae4590c601ca309 (plain)
ofshex dumpascii
0000 2d 2d 54 45 53 54 2d 2d 0a 54 65 73 74 20 63 68 72 28 29 20 61 6e 64 20 6f 72 64 28 29 20 66 75 --TEST--.Test.chr().and.ord().fu
0020 6e 63 74 69 6f 6e 73 0a 2d 2d 46 49 4c 45 2d 2d 0a 3c 3f 70 68 70 0a 2f 2a 20 50 72 6f 74 6f 74 nctions.--FILE--.<?php./*.Protot
0040 79 70 65 3a 20 73 74 72 69 6e 67 20 63 68 72 20 28 20 69 6e 74 20 24 61 73 63 69 69 20 29 3b 0a ype:.string.chr.(.int.$ascii.);.
0060 20 20 20 44 65 73 63 72 69 70 74 69 6f 6e 3a 20 52 65 74 75 72 6e 73 20 61 20 6f 6e 65 2d 63 68 ...Description:.Returns.a.one-ch
0080 61 72 61 63 74 65 72 20 73 74 72 69 6e 67 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 63 68 aracter.string.containing.the.ch
00a0 61 72 61 63 74 65 72 20 73 70 65 63 69 66 69 65 64 20 62 79 20 61 73 63 69 69 2e 0a 0a 20 20 20 aracter.specified.by.ascii......
00c0 50 72 6f 74 6f 74 79 70 65 3a 20 69 6e 74 20 6f 72 64 20 28 20 73 74 72 69 6e 67 20 24 73 74 72 Prototype:.int.ord.(.string.$str
00e0 69 6e 67 20 29 3b 0a 20 20 20 44 65 73 63 72 69 70 74 69 6f 6e 3a 20 52 65 74 75 72 6e 73 20 74 ing.);....Description:.Returns.t
0100 68 65 20 41 53 43 49 49 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 66 69 72 73 74 20 63 68 61 72 he.ASCII.value.of.the.first.char
0120 61 63 74 65 72 20 6f 66 20 73 74 72 69 6e 67 0a 2a 2f 0a 65 63 68 6f 20 22 2a 2a 2a 20 54 65 73 acter.of.string.*/.echo."***.Tes
0140 74 69 6e 67 20 6f 72 64 28 29 20 26 20 63 68 72 28 29 20 62 61 73 69 63 20 6f 70 65 72 61 74 69 ting.ord().&.chr().basic.operati
0160 6f 6e 73 20 2a 2a 2a 5c 6e 22 3b 0a 66 6f 72 28 24 69 3d 30 3b 20 24 69 3c 32 35 36 3b 20 24 69 ons.***\n";.for($i=0;.$i<256;.$i
0180 2b 2b 29 20 65 63 68 6f 20 21 6f 72 64 28 63 68 72 28 24 69 29 29 20 3d 3d 20 24 69 3b 0a 0a 2f ++).echo.!ord(chr($i)).==.$i;../
01a0 2a 20 6d 69 73 63 65 6c 6c 65 6f 75 73 20 69 6e 70 75 74 20 2a 2f 0a 65 63 68 6f 20 22 5c 6e 2a *.miscelleous.input.*/.echo."\n*
01c0 2a 2a 20 54 65 73 74 69 6e 67 20 63 68 72 28 29 20 75 73 61 67 65 20 76 61 72 69 61 74 69 6f 6e **.Testing.chr().usage.variation
01e0 73 20 2a 2a 2a 5c 6e 22 3b 0a 24 61 72 72 5f 74 65 73 74 20 3d 20 61 72 72 61 79 28 0a 20 20 22 s.***\n";.$arr_test.=.array(..."
0200 74 72 75 65 22 2c 0a 20 20 22 66 61 6c 73 65 22 2c 0a 20 20 74 72 75 65 2c 0a 20 20 66 61 6c 73 true",..."false",...true,...fals
0220 65 2c 0a 20 20 22 22 2c 0a 20 20 22 20 22 2c 0a 20 20 22 61 22 2c 0a 20 20 32 39 39 2c 0a 20 20 e,..."",...".",..."a",...299,...
0240 33 32 31 2c 0a 20 20 4e 55 4c 4c 2c 0a 20 20 27 5c 30 27 2c 0a 20 20 22 30 22 2c 0a 20 20 2d 33 321,...NULL,...'\0',..."0",...-3
0260 31 32 2c 0a 20 20 31 32 2e 39 39 39 2c 0a 20 20 2d 31 2e 30 35 30 30 39 2c 0a 20 20 31 31 30 30 12,...12.999,...-1.05009,...1100
0280 30 31 31 2c 0a 20 20 22 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 62 62 62 62 62 62 62 011,..."aaaaaaaaaaaaaaaaabbbbbbb
02a0 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
02c0 62 62 62 62 62 62 62 62 62 62 62 62 62 62 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 bbbbbbbbbbbbbbcccccccccccccccccc
02e0 63 63 63 63 63 63 63 63 63 63 63 63 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 ccccccccccccdddddddddddddddddddd
0300 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 22 2c 0a 20 20 22 61 62 63 64 dddddddddddddddddddddd",..."abcd
0320 5c 6e 61 62 63 64 5c 74 61 62 63 64 5c 30 61 62 63 64 5c 72 61 62 63 64 4e 55 4c 4c 61 62 63 64 \nabcd\tabcd\0abcd\rabcdNULLabcd
0340 65 66 67 68 22 2c 0a 20 20 22 61 62 63 64 5c 78 30 30 61 62 63 64 5c 78 30 30 61 62 63 64 5c 78 efgh",..."abcd\x00abcd\x00abcd\x
0360 30 30 61 62 63 64 65 66 67 68 69 6a 22 2c 0a 29 3b 0a 24 63 6f 75 6e 74 65 72 3d 31 3b 0a 66 6f 00abcdefghij",.);.$counter=1;.fo
0380 72 65 61 63 68 28 24 61 72 72 5f 74 65 73 74 20 61 73 20 24 76 61 72 29 7b 0a 20 20 65 63 68 6f reach($arr_test.as.$var){...echo
03a0 20 22 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 24 63 6f 75 6e 74 65 72 20 2d 2d 5c 6e 22 3b 0a 20 ."--.Iteration.$counter.--\n";..
03c0 20 76 61 72 5f 64 75 6d 70 28 20 63 68 72 28 24 76 61 72 29 20 29 3b 0a 20 20 24 63 6f 75 6e 74 .var_dump(.chr($var).);...$count
03e0 65 72 2b 2b 3b 0a 7d 0a 0a 65 63 68 6f 20 22 5c 6e 2a 2a 2a 20 54 65 73 74 69 6e 67 20 6f 72 64 er++;.}..echo."\n***.Testing.ord
0400 28 29 20 75 73 61 67 65 20 76 61 72 69 61 74 69 6f 6e 73 20 2a 2a 2a 5c 6e 22 3b 0a 24 63 6f 75 ().usage.variations.***\n";.$cou
0420 6e 74 65 72 3d 31 3b 0a 66 6f 72 65 61 63 68 28 24 61 72 72 5f 74 65 73 74 20 61 73 20 24 76 61 nter=1;.foreach($arr_test.as.$va
0440 72 29 7b 0a 20 20 65 63 68 6f 20 22 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 24 63 6f 75 6e 74 65 r){...echo."--.Iteration.$counte
0460 72 20 2d 2d 5c 6e 22 3b 0a 20 20 76 61 72 5f 64 75 6d 70 28 20 6f 72 64 28 24 76 61 72 29 20 29 r.--\n";...var_dump(.ord($var).)
0480 3b 0a 20 20 24 63 6f 75 6e 74 65 72 2b 2b 3b 0a 7d 0a 0a 2f 2a 20 45 72 72 6f 72 20 63 6f 6e 64 ;...$counter++;.}../*.Error.cond
04a0 69 74 69 6f 6e 73 20 2a 2f 0a 65 63 68 6f 20 22 5c 6e 2a 2a 2a 20 54 65 73 74 69 6e 67 20 63 68 itions.*/.echo."\n***.Testing.ch
04c0 72 28 29 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 6f 6e 73 20 2a 2a 2a 5c 6e 22 3b 0a 2f 2f 7a r().error.conditions.***\n";.//z
04e0 65 72 6f 20 61 72 67 75 6d 65 6e 74 73 0a 76 61 72 5f 64 75 6d 70 28 20 63 68 72 28 29 20 29 3b ero.arguments.var_dump(.chr().);
0500 0a 2f 2f 20 6d 6f 72 65 20 74 68 61 6e 20 65 78 70 65 63 74 65 64 20 6e 6f 2e 20 6f 66 20 61 72 .//.more.than.expected.no..of.ar
0520 67 73 0a 76 61 72 5f 64 75 6d 70 28 20 63 68 72 28 24 61 72 72 5f 74 65 73 74 5b 30 5d 2c 20 24 gs.var_dump(.chr($arr_test[0],.$
0540 61 72 72 5f 74 65 73 74 5b 31 5d 29 20 29 3b 0a 0a 0a 65 63 68 6f 20 22 5c 6e 2a 2a 2a 20 54 65 arr_test[1]).);...echo."\n***.Te
0560 73 74 69 6e 67 20 6f 72 64 28 29 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 6f 6e 73 20 2a 2a 2a sting.ord().error.conditions.***
0580 5c 6e 22 3b 0a 2f 2f 20 7a 65 72 6f 20 61 72 67 75 6d 65 6e 74 73 0a 76 61 72 5f 64 75 6d 70 28 \n";.//.zero.arguments.var_dump(
05a0 20 6f 72 64 28 29 20 29 3b 0a 2f 2f 20 6d 6f 72 65 20 74 68 61 6e 20 65 78 70 65 63 74 65 64 20 .ord().);.//.more.than.expected.
05c0 6e 6f 2e 20 6f 66 20 61 72 67 73 0a 76 61 72 5f 64 75 6d 70 28 20 6f 72 64 28 24 61 72 72 5f 74 no..of.args.var_dump(.ord($arr_t
05e0 65 73 74 5b 30 5d 2c 20 24 61 72 72 5f 74 65 73 74 5b 31 5d 29 20 29 3b 0a 0a 65 63 68 6f 20 22 est[0],.$arr_test[1]).);..echo."
0600 44 6f 6e 65 5c 6e 22 3b 0a 3f 3e 0a 2d 2d 45 58 50 45 43 54 46 2d 2d 0a 2a 2a 2a 20 54 65 73 74 Done\n";.?>.--EXPECTF--.***.Test
0620 69 6e 67 20 6f 72 64 28 29 20 26 20 63 68 72 28 29 20 62 61 73 69 63 20 6f 70 65 72 61 74 69 6f ing.ord().&.chr().basic.operatio
0640 6e 73 20 2a 2a 2a 0a 0a 2a 2a 2a 20 54 65 73 74 69 6e 67 20 63 68 72 28 29 20 75 73 61 67 65 20 ns.***..***.Testing.chr().usage.
0660 76 61 72 69 61 74 69 6f 6e 73 20 2a 2a 2a 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 20 2d 2d variations.***.--.Iteration.1.--
0680 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 32 20 2d 2d .string(1).".".--.Iteration.2.--
06a0 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 33 20 2d 2d .string(1).".".--.Iteration.3.--
06c0 0a 73 74 72 69 6e 67 28 31 29 20 22 01 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 34 20 2d 2d .string(1).".".--.Iteration.4.--
06e0 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 35 20 2d 2d .string(1).".".--.Iteration.5.--
0700 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 36 20 2d 2d .string(1).".".--.Iteration.6.--
0720 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 37 20 2d 2d .string(1).".".--.Iteration.7.--
0740 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 38 20 2d 2d .string(1).".".--.Iteration.8.--
0760 0a 73 74 72 69 6e 67 28 31 29 20 22 2b 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 39 20 2d 2d .string(1)."+".--.Iteration.9.--
0780 0a 73 74 72 69 6e 67 28 31 29 20 22 41 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 30 20 2d .string(1)."A".--.Iteration.10.-
07a0 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 31 20 -.string(1).".".--.Iteration.11.
07c0 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 32 --.string(1).".".--.Iteration.12
07e0 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 .--.string(1).".".--.Iteration.1
0800 33 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 c8 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 3.--.string(1).".".--.Iteration.
0820 31 34 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 0c 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 14.--.string(1).".".--.Iteration
0840 20 31 35 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 ff 22 0a 2d 2d 20 49 74 65 72 61 74 69 6f .15.--.string(1).".".--.Iteratio
0860 6e 20 31 36 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 eb 22 0a 2d 2d 20 49 74 65 72 61 74 69 n.16.--.string(1).".".--.Iterati
0880 6f 6e 20 31 37 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 74 on.17.--.string(1).".".--.Iterat
08a0 69 6f 6e 20 31 38 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 2d 2d 20 49 74 65 72 61 ion.18.--.string(1).".".--.Itera
08c0 74 69 6f 6e 20 31 39 20 2d 2d 0a 73 74 72 69 6e 67 28 31 29 20 22 00 22 0a 0a 2a 2a 2a 20 54 65 tion.19.--.string(1)."."..***.Te
08e0 73 74 69 6e 67 20 6f 72 64 28 29 20 75 73 61 67 65 20 76 61 72 69 61 74 69 6f 6e 73 20 2a 2a 2a sting.ord().usage.variations.***
0900 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 20 2d 2d 0a 69 6e 74 28 31 31 36 29 0a 2d 2d 20 49 .--.Iteration.1.--.int(116).--.I
0920 74 65 72 61 74 69 6f 6e 20 32 20 2d 2d 0a 69 6e 74 28 31 30 32 29 0a 2d 2d 20 49 74 65 72 61 74 teration.2.--.int(102).--.Iterat
0940 69 6f 6e 20 33 20 2d 2d 0a 69 6e 74 28 34 39 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 34 20 ion.3.--.int(49).--.Iteration.4.
0960 2d 2d 0a 69 6e 74 28 30 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 35 20 2d 2d 0a 69 6e 74 28 --.int(0).--.Iteration.5.--.int(
0980 30 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 36 20 2d 2d 0a 69 6e 74 28 33 32 29 0a 2d 2d 20 0).--.Iteration.6.--.int(32).--.
09a0 49 74 65 72 61 74 69 6f 6e 20 37 20 2d 2d 0a 69 6e 74 28 39 37 29 0a 2d 2d 20 49 74 65 72 61 74 Iteration.7.--.int(97).--.Iterat
09c0 69 6f 6e 20 38 20 2d 2d 0a 69 6e 74 28 35 30 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 39 20 ion.8.--.int(50).--.Iteration.9.
09e0 2d 2d 0a 69 6e 74 28 35 31 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 30 20 2d 2d 0a 69 6e --.int(51).--.Iteration.10.--.in
0a00 74 28 30 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 31 20 2d 2d 0a 69 6e 74 28 39 32 29 0a t(0).--.Iteration.11.--.int(92).
0a20 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 32 20 2d 2d 0a 69 6e 74 28 34 38 29 0a 2d 2d 20 49 74 --.Iteration.12.--.int(48).--.It
0a40 65 72 61 74 69 6f 6e 20 31 33 20 2d 2d 0a 69 6e 74 28 34 35 29 0a 2d 2d 20 49 74 65 72 61 74 69 eration.13.--.int(45).--.Iterati
0a60 6f 6e 20 31 34 20 2d 2d 0a 69 6e 74 28 34 39 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 35 on.14.--.int(49).--.Iteration.15
0a80 20 2d 2d 0a 69 6e 74 28 34 35 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 36 20 2d 2d 0a 69 .--.int(45).--.Iteration.16.--.i
0aa0 6e 74 28 34 39 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 37 20 2d 2d 0a 69 6e 74 28 39 37 nt(49).--.Iteration.17.--.int(97
0ac0 29 0a 2d 2d 20 49 74 65 72 61 74 69 6f 6e 20 31 38 20 2d 2d 0a 69 6e 74 28 39 37 29 0a 2d 2d 20 ).--.Iteration.18.--.int(97).--.
0ae0 49 74 65 72 61 74 69 6f 6e 20 31 39 20 2d 2d 0a 69 6e 74 28 39 37 29 0a 0a 2a 2a 2a 20 54 65 73 Iteration.19.--.int(97)..***.Tes
0b00 74 69 6e 67 20 63 68 72 28 29 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 6f 6e 73 20 2a 2a 2a 0a ting.chr().error.conditions.***.
0b20 0a 57 61 72 6e 69 6e 67 3a 20 57 72 6f 6e 67 20 70 61 72 61 6d 65 74 65 72 20 63 6f 75 6e 74 20 .Warning:.Wrong.parameter.count.
0b40 66 6f 72 20 63 68 72 28 29 20 69 6e 20 25 73 20 6f 6e 20 6c 69 6e 65 20 25 64 0a 4e 55 4c 4c 0a for.chr().in.%s.on.line.%d.NULL.
0b60 0a 57 61 72 6e 69 6e 67 3a 20 57 72 6f 6e 67 20 70 61 72 61 6d 65 74 65 72 20 63 6f 75 6e 74 20 .Warning:.Wrong.parameter.count.
0b80 66 6f 72 20 63 68 72 28 29 20 69 6e 20 25 73 20 6f 6e 20 6c 69 6e 65 20 25 64 0a 4e 55 4c 4c 0a for.chr().in.%s.on.line.%d.NULL.
0ba0 0a 2a 2a 2a 20 54 65 73 74 69 6e 67 20 6f 72 64 28 29 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 .***.Testing.ord().error.conditi
0bc0 6f 6e 73 20 2a 2a 2a 0a 0a 57 61 72 6e 69 6e 67 3a 20 6f 72 64 28 29 20 65 78 70 65 63 74 73 20 ons.***..Warning:.ord().expects.
0be0 65 78 61 63 74 6c 79 20 31 20 70 61 72 61 6d 65 74 65 72 2c 20 30 20 67 69 76 65 6e 20 69 6e 20 exactly.1.parameter,.0.given.in.
0c00 25 73 20 6f 6e 20 6c 69 6e 65 20 25 64 0a 4e 55 4c 4c 0a 0a 57 61 72 6e 69 6e 67 3a 20 6f 72 64 %s.on.line.%d.NULL..Warning:.ord
0c20 28 29 20 65 78 70 65 63 74 73 20 65 78 61 63 74 6c 79 20 31 20 70 61 72 61 6d 65 74 65 72 2c 20 ().expects.exactly.1.parameter,.
0c40 32 20 67 69 76 65 6e 20 69 6e 20 25 73 20 6f 6e 20 6c 69 6e 65 20 25 64 0a 4e 55 4c 4c 0a 44 6f 2.given.in.%s.on.line.%d.NULL.Do
0c60 6e 65 0a ne.