# HttpMessage::factory

(PECL pecl_http:1.4.0-1.5.5)

HttpMessage::factory — Create HttpMessage from string

### Description

static public HttpMessage HttpMessage::factory ([ string `$raw_message` [, string `$class_name = 'HttpMessage'` ]] )

Create an HttpMessage object from a string.

### Parameters

`raw_message`

  a single or several consecutive HTTP messages

`class_name`

  a class extending HttpMessage

### Return Values

Returns an HttpMessage object on success or NULL on failure.

### Errors/Exceptions

Throws HttpMalformedHeadersException.

### See Also

- HttpMessage::fromEnv().