1--TEST-- 2Test ucwords() function : usage variations - single quoted string 3--FILE-- 4<?php 5/* Prototype : string ucwords ( string $str ) 6 * Description: Uppercase the first character of each word in a string 7 * Source code: ext/standard/string.c 8*/ 9 10/* 11 * test ucwords() with different string prepared using single quote 12*/ 13 14echo "*** Testing ucwords() : usage variations ***\n"; 15 16// different strings containing regular chars and special chars 17$str_array = array( 18 // multiple spaces 19 'testing ucwords', 20 't e s t i n g u c w o r d s ', 21 22 // brackets in sentence 23 'testing function(ucwords)', 24 '(testing ( function (ucwords) )a )test', 25 '(t)', 26 ' ( t )t', 27 28 // using quote chars in sentence 29 '"testing",ucword,"test"', 30 '"t""t",test, t', 31 '\'t \'t\',test', 32 33 // using other white spaces 34 '\ttesting\ttesting\tucwords', 35 'testing\rucwords testing ucwords', 36 'testing\fucwords \f testing \nucwords', 37 '\ntesting\nucwords\n testing \n ucwords', 38 'using\vvertical\vtab', 39 40 //using special chars in sentence 41 't@@#$% %test ^test &test *test +test -test', 42 '!test ~test `test` =test= @test@test.com', 43 '/test/r\test\ucwords\t\y\y\u\3 \yy\ /uu/', 44 45 //only special chars 46 '!@#$%^&*()_+=-`~' 47); 48 49// loop through the $str_array array to test ucwords on each element 50$iteration = 1; 51for($index = 0; $index < count($str_array); $index++) { 52 echo "-- Iteration $iteration --\n"; 53 var_dump( ucwords($str_array[$index]) ); 54 $iteration++; 55} 56 57echo "Done\n"; 58?> 59--EXPECT-- 60*** Testing ucwords() : usage variations *** 61-- Iteration 1 -- 62string(18) "Testing Ucwords" 63-- Iteration 2 -- 64string(30) "T E S T I N G U C W O R D S " 65-- Iteration 3 -- 66string(25) "Testing Function(ucwords)" 67-- Iteration 4 -- 68string(38) "(testing ( Function (ucwords) )a )test" 69-- Iteration 5 -- 70string(3) "(t)" 71-- Iteration 6 -- 72string(7) " ( T )t" 73-- Iteration 7 -- 74string(23) ""testing",ucword,"test"" 75-- Iteration 8 -- 76string(14) ""t""t",test, T" 77-- Iteration 9 -- 78string(11) "'t 't',test" 79-- Iteration 10 -- 80string(27) "\ttesting\ttesting\tucwords" 81-- Iteration 11 -- 82string(32) "Testing\rucwords Testing Ucwords" 83-- Iteration 12 -- 84string(37) "Testing\fucwords \f Testing \nucwords" 85-- Iteration 13 -- 86string(39) "\ntesting\nucwords\n Testing \n Ucwords" 87-- Iteration 14 -- 88string(20) "Using\vvertical\vtab" 89-- Iteration 15 -- 90string(42) "T@@#$% %test ^test &test *test +test -test" 91-- Iteration 16 -- 92string(40) "!test ~test `test` =test= @test@test.com" 93-- Iteration 17 -- 94string(40) "/test/r\test\ucwords\t\y\y\u\3 \yy\ /uu/" 95-- Iteration 18 -- 96string(16) "!@#$%^&*()_+=-`~" 97Done 98