PHP Internet functions

Quick reference to the Internet functions of PHP.

HTTP and HTML functions
Function Returns Does what
header(string [, replace [, http_response_code]]) Integer Sends the header
headers_sent([file [, line]]) Boolean Checks if headers have been sent
http_build_query(query_array [, num_prefix [, arg_separator [, enc_type]]]) String Returns URL-encoded query string from "query_array". Default enc_type: RC1738
setcookie(name [, value [expire [, path [, domain [, secure [, httponly]]]]]) Integer Set cookie with "name" and optionally "value" etc.
get_browser([user_agent [, return_array]]) Mixed Returns browser information
get_html_translation_table([table [, flags [, encoding]]]) Array Returns the translation table used by htmlspecialchars() and htmlentities()
get_meta_tags(filename [, use_inc_path]) Array Returns meta tags from "filename"
get_headers(url [, format]) Array Returns headers for "url" (HTTP request)
nl2br(string [, is_xhtml]) String Inserts "<br>" before linebreaks in "string"
parse_url(string [, component]) Mixed Parses URL into components
Connection functions
Function Returns Does what
connection_aborted() Integer Shows if connection was aborted
connection_status() Integer Returns status of connection
connection_timeout() Integer Shows if script timed out
ignore_user_abort([value]) Integer Sets if disconnecting client will terminate script
Session functions
Function Returns Does what
session_cache_limiter(string) String Sets or returns the cache limiter
session_decode(string) Boolean Decodes data specified by "string"
session_destroy() Boolean Destroys session data
session_encode() String Encodes current session data into string
session_get_cookie_params() Array Returns cookie data for session
session_id(string) String Sets or returns session ID
session_is_registered(string) Boolean Shows if the var "string" is in current session
session_module_name(string) String Sets or returns session module name
session_name(string) String Sets or returns session name
session_register(name [, ...]) Boolean Registers variable(s) of session
session_save_path(string) String Sets or returns session save path
session_set_cookie_params(lifetime [, path [, domain [, secure [, httponly]]]]) Nothing Sets session cookie parameters
session_set_save_handler(open, close, read, write, destroy, gc) Nothing Sets user-level session save function
session_start() Boolean Starts a session
session_unregister(string) Boolean Un-registers "string" from session
session_unset() Nothing Frees all session vaiables
CURL (Client URL Library) functions
Function Returns Does what
curl_close(handle) Nothing Closes CURL-session
curl_exec(handle) Boolean Executes CURL-session
curl_init([url]) Integer Set up new CURL-session, return its handle.
curl_setopt(handle, option, value) Booblean Set "option" to "value" for "handle".
Apache-specific functions
Function Returns Does what
apache_lookup_uri(filename) Object Returns information about "filename" (an URI)
apache_note(note_name [, note_value]) String Get value from notes table. Set value, if "note_value"
getallheaders() Array Returns HTTP headers
virtual(filename) Integer Eg. include the CGI "filename"
Mail functions
Function Returns Does what
mail(to, subject, message [, extra_headers [, extra_parameters]]) Boolean Sends an email
Encoding functions
Function Returns Does what
base64_decode(string [, strict]) String Decodes a B64-encoded string
base64_encode(string) String Encodes a string (Base 64)
htmlentities(string, [, flags [, charset [, double_encode]]]) String Converts characters to HTML-entities
html_entity_decode(string, [, flags [, encoding]]) String Converts HTML-entities to characters
htmlspecialchars(string, [, flags [, charset [, double_encode]]]) String Converts all special characters to HTML-entities
htmlspecialchars_decode(string, [, flags]) String Converts special HTML-entities to characters
rawurldecode(string) String Decodes a rawurl-encoded string
rawurlencode(string) String Encodes everything except "-", "_", "." (RFC1738)
urldecode(string) String Decodes an url-encoded string
urlencode(string) String Url-encodes a string
quoted_printable_encode(string) String Convert a 8 bit string to a quoted-printable string
quoted_printable_decode(string) String Convert a quoted-printable string to a 8 bit string
convert_uuencode(string) String Encodes Uuencoded string
convert_uudecode(string) String Decodes Uuencoded string
str_rot13(string) String Encodes/decodes "string" with ROT 13
crypt(string [, salt]) String DES-encrypts "string" using (2-character) "salt"
Character-escape functions
Function Returns Does what
addcslashes(string, charlist) String Adds slashes before characters in "charlist"
stripcslashes(string) String Removes slashes inserted with addcslashes()
addslashes(string) String Adds slashes to DB-sensitive characters
stripslashes(string) String Removes slashes from "string"
quotemeta(string) String Escapes meta-characters in "string"
strip_tags(string [, allowed_tags]) String Removes HTML and PHP tags from "string"

See also: PHP Network functions.

More: