big update's coming
[mdref/mdref-http] / http / Message / Body / addPart.md
1 # http\Message\Body http\Message\Body::addPart(http\Message $part)
2
3 Add a part to a multipart body.
4
5 ## Params:
6
7 * http\Message $part
8 The message part.
9
10 ## Returns:
11
12 * http\Message\Body, self.
13
14 ## Throws:
15
16 * http\Exception\InvalidArgumentException
17 * http\Exception\RuntimeException
18
19 ## Example:
20
21 <?php
22 $multi = new http\Message\Body;
23 $multi->addPart(new http\Message("Content-type: text/plain\n\nHello part 1!"));
24 $multi->addPart(new http\Message("Content-type: text/plain\n\nHello part 2!"));
25
26 echo $multi;
27 ?>
28
29 Yields:
30
31 --8a72b190.3fe908df
32 Content-Type: text/plain
33 Content-Length: 13
34
35 Hello part 1!
36 --8a72b190.3fe908df
37 Content-Type: text/plain
38 Content-Length: 13
39
40 Hello part 2!
41 --8a72b190.3fe908df--