Learn how to handle URLs in PHP.
|
URL Encoding Functions Function Purpose & Features |
PHP provides several functions for URL encoding, including the urlencode(), rawurlencode(), and http_build_query() functions, each with a distinct purpose and behavior. |
|---|---|
|
urlencode() Encoding a URL Query Parameter Value |
The urlencode() function is used to encode a string for use as a URL query parameter value, making it ideal for passing variables between pages. |
|
rawurlencode() Safely Encoding URI Components |
The rawurlencode() function encodes individual URI components—like search terms, filenames, or query values—according to RFC 3986. |
|
http_build_query() Build Query Strings from Arrays or Objects |
The http_build_query() function encodes an array or object into a URL-compatible query string. It's especially useful when building HTTP requests or generating URLs from structured data. |
|
URL Decoding Functions Function Purpose & Features |
PHP provides several functions for URL decoding, including urldecode(), rawurldecode(), and parse_str(), each with a distinct purpose and behavior. |
|
urldecode() Decoding URLs Encoded with urlencode() |
The urldecode() function decodes a URL string that was previously encoded using urlencode(). It's typically used to decode URL query parameter values that have been passed in an encoded form. |
|
rawurldecode() Decoding URLs Encoded with rawurlencode() |
The rawurldecode() function decodes a URL string that was previously encoded using rawurlencode(). It's typically used to decode URI components such as path segments or query parameter values. |
|
parse_str() Parse URL Query Strings into Variables |
The parse_str() function parses a URL-encoded query string and stores the result as variables. It's typically used to decode strings generated by http_build_query(). |