File: ucwords_variation2.phpt

package info (click to toggle)
php5 5.6.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 150,376 kB
  • sloc: ansic: 727,510; php: 21,966; sh: 12,356; cpp: 8,763; xml: 6,105; yacc: 1,551; exp: 1,514; makefile: 1,461; pascal: 1,048; awk: 538; perl: 315; sql: 22
file content (98 lines) | stat: -rw-r--r-- 2,048 bytes parent folder | download | duplicates (4)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
--TEST--
Test ucwords() function : usage variations - heredoc strings
--FILE--
<?php
/* Prototype  : string ucwords ( string $str )
 * Description: Uppercase the first character of each word in a string
 * Source code: ext/standard/string.c
*/

/*
 * test ucwords() with different string prepared using heredoc
*/

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

// Null here doc string
$null_string = <<<EOT
EOT;

// Heredoc string with blank line
$blank_line = <<<EOT

EOT;

// here doc with multiline string
$multiline_string = <<<EOT
testing ucword() with
multiline string using
heredoc
EOT;

// here doc with different whitespaces
$diff_whitespaces = <<<EOT
testing\rucword(str)\twith
multiline   string\t\tusing
heredoc\nstring.with\vdifferent\fwhite\vspaces
EOT;

// here doc with numeric values
$numeric_string = <<<EOT
12sting 123string 4567
string\t123string\r12 test\n5test
EOT;

// heredoc with quote chars & slash
$quote_char_string = <<<EOT
it's bright,but i cann't see it.
"things in double quote"
'things in single quote'
this\line is /with\slashs
EOT;

$heredoc_strings = array(
  $null_string,
  $blank_line,
  $multiline_string,
  $diff_whitespaces,
  $numeric_string,
  $quote_char_string
);

// loop through $heredoc_strings element and check the working on ucwords()
$count = 1;
for($index =0; $index < count($heredoc_strings); $index ++) {
  echo "-- Iteration $count --\n";
  var_dump( ucwords($heredoc_strings[$index]) );
  $count ++;
}

echo "Done\n";
?>
--EXPECTF--
*** Testing ucwords() : usage variations ***
-- Iteration 1 --
string(0) ""
-- Iteration 2 --
string(0) ""
-- Iteration 3 --
string(52) "Testing Ucword() With
Multiline String Using
Heredoc"
-- Iteration 4 --
string(93) "Testing
Ucword(str)	With
Multiline   String		Using
Heredoc
String.withDifferentWhiteSpaces"
-- Iteration 5 --
string(53) "12sting 123string 4567
String	123string
12 Test
5test"
-- Iteration 6 --
string(108) "It's Bright,but I Cann't See It.
"things In Double Quote"
'things In Single Quote'
This\line Is /with\slashs"
Done