HTTP Functions
These functions assist you in dealing with the HTTP protocol. The encoding and decoding functions are not normally needed, as PHP takes care of these actions automatically. But there are cases where the actions need to be done manually, so these functions are provided. The header and cookie functions are very useful for sending either custom HTTP headers or cookies.
Here are the HTTP functions in PHP:
- int header(string str)
Send a raw HTTP header
- array parse_url(string url)
Parse a URL and return its components in an array
- string rawurldecode(string str)
Decode a URL-encoded string
- string rawurlencode(string str)
URL-encode a string
- void setcookie(string name, string value, int expire, string path, string domain, int secure)
Send a cookie
- string urldecode(string str)
Decode a URL-encoded string
- string urlencode(string str)
URL-encode a string
Apache-Specific Functions
The following HTTP functions are available only if PHP is running as an Apache module.
- class apache_lookup_uri(string URI)
Perform a partial request of the given URI to obtain information about it
- string apache_note(string note_name [, string note_value])
Get and set Apache request notes
- array getallheaders(void)
Fetch all HTTP request headers
- int virtual(string filename)
Perform an Apache subrequest
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access