File: join_variation4.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (73 lines) | stat: -rw-r--r-- 2,019 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--TEST--
Test join() function : usage variations - different values for 'glue' argument
--FILE--
<?php
/*
 * test join() by passing different glue arguments
*/

echo "*** Testing join() : usage variations ***\n";

$glues = array (
  "TRUE",
  true,
  false,
  array("key1", "key2"),
  "",
  " ",
  "string\x00between",
  -1.566599999999999,
  -0,
  '\0'
);

$pieces = array (
  2,
  0,
  -639,
  -1.3444,
  true,
  "PHP",
  false,
  "",
  " ",
  6999.99999999,
  "string\x00with\x00...\0"
);
/* loop through  each element of $glues and call join */
$counter = 1;
for($index = 0; $index < count($glues); $index ++) {
  echo "-- Iteration $counter --\n";
  try {
    var_dump(join($glues[$index], $pieces));
  } catch (TypeError $exception) {
    echo $exception->getMessage() . "\n";
  }
  $counter++;
}

echo "Done\n";
?>
--EXPECTF--
*** Testing join() : usage variations ***
-- Iteration 1 --
string(87) "2TRUE0TRUE-639TRUE-1.3444TRUE1TRUEPHPTRUETRUETRUE TRUE6999.99999999TRUEstring%0with%0...%0"
-- Iteration 2 --
string(57) "2101-6391-1.3444111PHP111 16999.999999991string%0with%0...%0"
-- Iteration 3 --
string(47) "20-639-1.34441PHP 6999.99999999string%0with%0...%0"
-- Iteration 4 --
join(): Argument #1 ($separator) must be of type string, array given
-- Iteration 5 --
string(47) "20-639-1.34441PHP 6999.99999999string%0with%0...%0"
-- Iteration 6 --
string(57) "2 0 -639 -1.3444 1 PHP     6999.99999999 string%0with%0...%0"
-- Iteration 7 --
string(187) "2string%0between0string%0between-639string%0between-1.3444string%0between1string%0betweenPHPstring%0betweenstring%0betweenstring%0between string%0between6999.99999999string%0betweenstring%0with%0...%0"
-- Iteration 8 --
string(117) "2-1.56660-1.5666-639-1.5666-1.3444-1.56661-1.5666PHP-1.5666-1.5666-1.5666 -1.56666999.99999999-1.5666string%0with%0...%0"
-- Iteration 9 --
string(57) "2000-6390-1.3444010PHP000 06999.999999990string%0with%0...%0"
-- Iteration 10 --
string(67) "2\00\0-639\0-1.3444\01\0PHP\0\0\0 \06999.99999999\0string%0with%0...%0"
Done