PHP URL Functions

About This Index
This page is the PHP URL Functions index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn how encoding, query strings and URL parts work on /php/url. Use this page when you need a specific helper such as urlencode(), http_build_query(), or parse_url().
Start with urlencode() and http_build_query(), then move on to parse_url() and the base64 pair.
How to Call a URL Function
URL helpers are global functions—pass the text or array and use the return value:
<?php
$value = urlencode("php & mysql"); // php+%26+mysql
$query = http_build_query(["q" => "php"]); // q=php
$parts = parse_url("https://example.com/a?x=1");
$host = parse_url("https://example.com/a", PHP_URL_HOST); // example.com PHP URL Functions Table
All function guides in this PHP tutorial series (10 tutorials in 3 categories).
Encode & decode
6 functionsMake text safe for a URL, or turn it back into plain text.
| Function | Description | Tutorial |
|---|---|---|
urlencode() | Encodes a string for a URL query, writing spaces as plus signs. | Try it |
urldecode() | Decodes a URL-encoded string and turns plus signs into spaces. | Try it |
rawurlencode() | Encodes a string for use in a URL path using RFC 3986. | Try it |
rawurldecode() | Decodes %XX sequences in a URL without changing plus signs. | Try it |
base64_encode() | Encodes data as a base64 string. | Try it |
base64_decode() | Decodes a base64 string back to the original data. | Try it |
Build & parse
2 functionsCreate a query string from an array, or split a URL into its parts.
| Function | Description | Tutorial |
|---|---|---|
http_build_query() | Builds a URL query string from an array. | Try it |
parse_url() | Splits a URL into its parts such as host, path and query. | Try it |
Fetch page info
2 functionsRead headers and meta tags from a web page.
| Function | Description | Tutorial |
|---|---|---|
get_headers() | Fetches the response headers a server sends for a URL. | Try it |
get_meta_tags() | Reads the meta tags from a web page or an HTML file. | Try it |
Frequently Asked Questions
Start with base64_decode()
Open the first guide—syntax, examples, and FAQs.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
15 people found this page helpful
