1--- %YAML:1.0 2test: Strings 3brief: > 4 Any group of characters beginning with an 5 alphabetic or numeric character is a string, 6 unless it belongs to one of the groups below 7 (such as an Integer or Time). 8yaml: | 9 String 10php: | 11 'String' 12--- 13test: String characters 14brief: > 15 A string can contain any alphabetic or 16 numeric character, along with many 17 punctuation characters, including the 18 period, dash, space, quotes, exclamation, and 19 question mark. 20yaml: | 21 - What's Yaml? 22 - It's for writing data structures in plain text. 23 - And? 24 - And what? That's not good enough for you? 25 - No, I mean, "And what about Yaml?" 26 - Oh, oh yeah. Uh.. Yaml for Ruby. 27php: | 28 [ 29 "What's Yaml?", 30 "It's for writing data structures in plain text.", 31 "And?", 32 "And what? That's not good enough for you?", 33 "No, I mean, \"And what about Yaml?\"", 34 "Oh, oh yeah. Uh.. Yaml for Ruby." 35 ] 36--- 37test: Indicators in Strings 38brief: > 39 Be careful using indicators in strings. In particular, 40 the comma, colon, and pound sign must be used carefully. 41yaml: | 42 the colon followed by space is an indicator: but is a string:right here 43 same for the pound sign: here we have it#in a string 44 the comma can, honestly, be used in most cases: [ but not in, inline collections ] 45php: | 46 [ 47 'the colon followed by space is an indicator' => 'but is a string:right here', 48 'same for the pound sign' => 'here we have it#in a string', 49 'the comma can, honestly, be used in most cases' => ['but not in', 'inline collections'] 50 ] 51--- 52test: Forcing Strings 53brief: > 54 Any YAML type can be forced into a string using the 55 explicit !!str method. 56yaml: | 57 date string: !!str 2001-08-01 58 number string: !!str 192 59php: | 60 [ 61 'date string' => '2001-08-01', 62 'number string' => '192' 63 ] 64--- 65test: Single-quoted Strings 66brief: > 67 You can also enclose your strings within single quotes, 68 which allows use of slashes, colons, and other indicators 69 freely. Inside single quotes, you can represent a single 70 quote in your string by using two single quotes next to 71 each other. 72yaml: | 73 all my favorite symbols: '#:!/%.)' 74 a few i hate: '&(*' 75 why do i hate them?: 'it''s very hard to explain' 76 entities: '£ me' 77php: | 78 [ 79 'all my favorite symbols' => '#:!/%.)', 80 'a few i hate' => '&(*', 81 'why do i hate them?' => 'it\'s very hard to explain', 82 'entities' => '£ me' 83 ] 84--- 85test: Double-quoted Strings 86brief: > 87 Enclosing strings in double quotes allows you 88 to use escapings to represent ASCII and 89 Unicode characters. 90yaml: | 91 i know where i want my line breaks: "one here\nand another here\n" 92php: | 93 [ 94 'i know where i want my line breaks' => "one here\nand another here\n" 95 ] 96--- 97test: Multi-line Quoted Strings 98todo: true 99brief: > 100 Both single- and double-quoted strings may be 101 carried on to new lines in your YAML document. 102 They must be indented a step and indentation 103 is interpreted as a single space. 104yaml: | 105 i want a long string: "so i'm going to 106 let it go on and on to other lines 107 until i end it with a quote." 108php: | 109 ['i want a long string' => "so i'm going to ". 110 "let it go on and on to other lines ". 111 "until i end it with a quote." 112 ] 113 114--- 115test: Plain scalars 116todo: true 117brief: > 118 Unquoted strings may also span multiple lines, if they 119 are free of YAML space indicators and indented. 120yaml: | 121 - My little toe is broken in two places; 122 - I'm crazy to have skied this way; 123 - I'm not the craziest he's seen, since there was always the German guy 124 who skied for 3 hours on a broken shin bone (just below the kneecap); 125 - Nevertheless, second place is respectable, and he doesn't 126 recommend going for the record; 127 - He's going to put my foot in plaster for a month; 128 - This would impair my skiing ability somewhat for the 129 duration, as can be imagined. 130php: | 131 [ 132 "My little toe is broken in two places;", 133 "I'm crazy to have skied this way;", 134 "I'm not the craziest he's seen, since there was always ". 135 "the German guy who skied for 3 hours on a broken shin ". 136 "bone (just below the kneecap);", 137 "Nevertheless, second place is respectable, and he doesn't ". 138 "recommend going for the record;", 139 "He's going to put my foot in plaster for a month;", 140 "This would impair my skiing ability somewhat for the duration, ". 141 "as can be imagined." 142 ] 143--- 144test: 'Null' 145brief: > 146 You can use the tilde '~' character for a null value. 147yaml: | 148 name: Mr. Show 149 hosted by: Bob and David 150 date of next season: ~ 151php: | 152 [ 153 'name' => 'Mr. Show', 154 'hosted by' => 'Bob and David', 155 'date of next season' => null 156 ] 157--- 158test: Boolean 159brief: > 160 You can use 'true' and 'false' for Boolean values. 161yaml: | 162 Is Gus a Liar?: true 163 Do I rely on Gus for Sustenance?: false 164php: | 165 [ 166 'Is Gus a Liar?' => true, 167 'Do I rely on Gus for Sustenance?' => false 168 ] 169--- 170test: Integers 171dump_skip: true 172brief: > 173 An integer is a series of numbers, optionally 174 starting with a positive or negative sign. Integers 175 may also contain commas for readability. 176yaml: | 177 zero: 0 178 simple: 12 179php: | 180 [ 181 'zero' => 0, 182 'simple' => 12, 183 ] 184--- 185test: Floats 186dump_skip: true 187brief: > 188 Floats are represented by numbers with decimals, 189 allowing for scientific notation, as well as 190 positive and negative infinity and "not a number." 191yaml: | 192 a simple float: 2.00 193 scientific notation: 1.00009e+3 194php: | 195 [ 196 'a simple float' => 2.0, 197 'scientific notation' => 1000.09 198 ] 199--- 200test: Time 201todo: true 202brief: > 203 You can represent timestamps by using 204 ISO8601 format, or a variation which 205 allows spaces between the date, time and 206 time zone. 207yaml: | 208 iso8601: 2001-12-14t21:59:43.10-05:00 209 space separated: 2001-12-14 21:59:43.10 -05:00 210php: | 211 [ 212 'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), 213 'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ) 214 ] 215--- 216test: Date 217todo: true 218brief: > 219 A date can be represented by its year, 220 month and day in ISO8601 order. 221yaml: | 222 1976-07-31 223php: | 224 date( 1976, 7, 31 ) 225