= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // $_POST - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // $_REQUEST - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // $_COOKIE - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // $http_response_header - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== USING FUNCTIONS (34) // checkdnsrr() - PHP_4, PHP_5, PHP_7, PHP_8 // closelog() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | dns_check_record() - PHP_5, PHP_7, PHP_8 // OFFLINE | dns_get_mx() - PHP_5, PHP_7, PHP_8 // OFFLINE | dns_get_record() - PHP_5, PHP_7, PHP_8 // fsockopen() - PHP_4, PHP_5, PHP_7, PHP_8 // gethostbyaddr() - PHP_4, PHP_5, PHP_7, PHP_8 // gethostbyname() - PHP_4, PHP_5, PHP_7, PHP_8 // gethostbynamel() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | gethostname() - PHP_5 >= PHP_5_3_0, PHP_7, PHP_8 // getmxrr() - PHP_4, PHP_5, PHP_7, PHP_8 // getprotobyname() - PHP_4, PHP_5, PHP_7, PHP_8 // getprotobynumber() - PHP_4, PHP_5, PHP_7, PHP_8 // getservbyname() - PHP_4, PHP_5, PHP_7, PHP_8 // getservbyport() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | header_register_callback() - PHP_5 >= PHP_5_4_0, PHP_7, PHP_8 // OFFLINE | header_remove() - PHP_5 >= PHP_5_3_0, PHP_7, PHP_8 // header() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | headers_list() - PHP_5, PHP_7, PHP_8 // headers_sent() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | http_response_code() - PHP_5 >= PHP_5_4_0, PHP_7, PHP_8 // OFFLINE | inet_ntop() - PHP_5 >= PHP_5_1_0, PHP_7, PHP_8 // OFFLINE | inet_pton() - PHP_5 >= PHP_5_1_0, PHP_7, PHP_8 // ip2long() - PHP_4, PHP_5, PHP_7, PHP_8 // long2ip() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | net_get_interfaces() - PHP_7 >= PHP_7_3, PHP_8 // openlog() - PHP_4, PHP_5, PHP_7, PHP_8 // pfsockopen() - PHP_4, PHP_5, PHP_7, PHP_8 // setcookie() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | setrawcookie() - PHP_5, PHP_7, PHP_8 // socket_get_status() - PHP_4, PHP_5, PHP_7, PHP_8 // socket_set_blocking() - PHP_4, PHP_5, PHP_7, PHP_8 // socket_set_timeout() - PHP_4, PHP_5, PHP_7, PHP_8 // syslog() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== USING CLASSES (0) // ============================== USING DATA_TYPES (9) // array // bool // string // false // int // resource // float // callable // void // ============================== END // REQUIREMENTS // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK // ============================== ABOUT // PHP Manual / Function Reference / Other Services / Network // URL: https://www.php.net/manual/en/book.network.php // ============================== DESCRIPTION // NETWORK // FEATURES_COOKIES // RFC_6265_HTTP_STATE_MANAGEMENT_MECHANISM // RFC_2109_HTTP_STATE_MANAGEMENT_MECHANISM // // NETWORK - BEGIN // Network // // INTRODUCTION // INSTALLING_CONFIGURING // PREDEFINED_CONSTANTS // NETWORK_FUNCTIONS // // INTRODUCTION - BEGIN // Introduction // // Provides various networking functions. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/intro.network.php // INTRODUCTION - END // // INSTALLING_CONFIGURING - BEGIN // Installing/Configuring // // REQUIREMENTS // INSTALLATION // RUNTIME_CONFIGURATION // RESOURCE_TYPES // // REQUIREMENTS - BEGIN // Requirements // // Functions checkdnsrr(), getmxrr() and dns_get_record() requires Bind on Linux. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/network.requirements.php // REQUIREMENTS - END // // INSTALLATION - BEGIN // Installation // // There is no installation needed to use these functions; they are part of the PHP core. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/network.installation.php // INSTALLATION - END // // RUNTIME_CONFIGURATION - BEGIN // Runtime Configuration // // This extension has no configuration directives defined in php.ini. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/network.configuration.php // RUNTIME_CONFIGURATION - END // // RESOURCE_TYPES - BEGIN // Resource Types // // This extension defines a file pointer resource returned by fsockopen() and pfsockopen(). // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/network.resources.php // RESOURCE_TYPES - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/network.setup.php // INSTALLING_CONFIGURING - END // // PREDEFINED_CONSTANTS - BEGIN // Predefined Constants // // The constants below are always available as part of the PHP core. // openlog() Options // Constant - Description // LOG_CONS - if there is an error while sending data to the system logger, write directly to the system console // LOG_NDELAY - open the connection to the logger immediately // LOG_ODELAY - (default) delay opening the connection until the first message is logged // LOG_NOWAIT - // LOG_PERROR - print log message also to standard error // LOG_PID - include - PID with each message // // openlog() Facilities // Constant - Description // LOG_AUTH - security/authorization messages (use LOG_AUTHPRIV instead in systems where that constant is defined) // LOG_AUTHPRIV - security/authorization messages (private) // LOG_CRON - clock daemon (cron and at) // LOG_DAEMON - other system daemons // LOG_KERN - kernel messages // LOG_LOCAL0 ... LOG_LOCAL7 - reserved for local use, these are not available in Windows // LOG_LPR - line printer subsystem // LOG_MAIL - mail subsystem // LOG_NEWS - USENET news subsystem // LOG_SYSLOG - messages generated internally by syslogd // LOG_USER - generic user-level messages // LOG_UUCP - UUCP subsystem // // syslog() Priorities (in descending order) // Constant - Description // LOG_EMERG - system is unusable // LOG_ALERT - action must be taken immediately // LOG_CRIT - critical conditions // LOG_ERR - error conditions // LOG_WARNING - warning conditions // LOG_NOTICE - normal, but significant, condition // LOG_INFO - informational message // LOG_DEBUG - debug-level message // // dns_get_record() Options // Constant - Description // DNS_A - IPv4 Address Resource // DNS_CAA - Certification Authority Authorization Resource (available as of PHP 7.0.16 and 7.1.2) // DNS_MX - Mail Exchanger Resource // DNS_CNAME - Alias (Canonical Name) Resource // DNS_NS - Authoritative Name Server Resource // DNS_PTR - Pointer Resource // DNS_HINFO - Host Info Resource (See IANA's > Operating System Names for the meaning of these values) // DNS_SOA - Start of Authority Resource // DNS_TXT - Text Resource // DNS_ANY - Any Resource Record. On most systems this returns all resource records, however it should not be counted upon for critical uses. Try DNS_ALL instead. // DNS_AAAA - IPv6 Address Resource // DNS_ALL - Iteratively query the name server for each available record type. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/network.constants.php // PREDEFINED_CONSTANTS - END // // NETWORK_FUNCTIONS - BEGIN // Network Functions // // Table of Contents // * checkdnsrr - Check DNS records corresponding to a given Internet host name or IP address // * closelog - Close connection to system logger // * dns_check_record - Alias of checkdnsrr // * dns_get_mx - Alias of getmxrr // * dns_get_record - Fetch DNS Resource Records associated with a hostname // * fsockopen - Open Internet or Unix domain socket connection // * gethostbyaddr - Get the Internet host name corresponding to a given IP address // * gethostbyname - Get the IPv4 address corresponding to a given Internet host name // * gethostbynamel - Get a list of IPv4 addresses corresponding to a given Internet host name // * gethostname - Gets the host name // * getmxrr - Get MX records corresponding to a given Internet host name // * getprotobyname - Get protocol number associated with protocol name // * getprotobynumber - Get protocol name associated with protocol number // * getservbyname - Get port number associated with an Internet service and protocol // * getservbyport - Get Internet service which corresponds to port and protocol // * header_register_callback - Call a header function // * header_remove - Remove previously set headers // * header - Send a raw HTTP header // * headers_list - Returns a list of response headers sent (or ready to send) // * headers_sent - Checks if or where headers have been sent // * http_response_code - Get or Set the HTTP response code // * inet_ntop - Converts a packed internet address to a human readable representation // * inet_pton - Converts a human readable IP address to its packed in_addr representation // * ip2long - Converts a string containing an (IPv4) Internet Protocol dotted address into a long integer // * long2ip - Converts a long integer address into a string in (IPv4) Internet standard dotted format // * net_get_interfaces - Get network interfaces // * openlog - Open connection to system logger // * pfsockopen - Open persistent Internet or Unix domain socket connection // * setcookie - Send a cookie // * setrawcookie - Send a cookie without urlencoding the cookie value // * socket_get_status - Alias of stream_get_meta_data // * socket_set_blocking - Alias of stream_set_blocking // * socket_set_timeout - Alias of stream_set_timeout // * syslog - Generate a system log message // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/ref.network.php // NETWORK_FUNCTIONS - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/book.network.php // NETWORK - END // // FEATURES_COOKIES - BEGIN // Cookies (PHP Manual / Features / Cookies) // // PHP transparently supports HTTP cookies. Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. You can set cookies using the setcookie() or setrawcookie() function. Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser. This is the same limitation that header() has. You can use the output buffering functions to delay the script output until you have decided whether or not to set any cookies or send any headers. // Any cookies sent to server from the client will automatically be included into a $_COOKIE auto-global array if variables_order contains "C". If you wish to assign multiple values to a single cookie, just add [] to the cookie name. // For more details, including notes on browser bugs, see the setcookie() and setrawcookie() function. // // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/features.cookies.php // FEATURES_COOKIES - END // // RFC_6265_HTTP_STATE_MANAGEMENT_MECHANISM - BEGIN // RFC 6265 - HTTP State Management Mechanism // // Internet Engineering Task Force (IETF) A. Barth // Request for Comments: 6265 U.C. Berkeley // Obsoletes: 2965 April 2011 // Category: Standards Track // ISSN: 2070-1721 // HTTP State Management Mechanism // // Abstract // // This document defines the HTTP Cookie and Set-Cookie header fields. // These header fields can be used by HTTP servers to store state // (called cookies) at HTTP user agents, letting the servers maintain a // stateful session over the mostly stateless HTTP protocol. Although // cookies have many historical infelicities that degrade their security // and privacy, the Cookie and Set-Cookie header fields are widely used // on the Internet. This document obsoletes RFC 2965. // // Status of This Memo // // This is an Internet Standards Track document. // // This document is a product of the Internet Engineering Task Force // (IETF). It represents the consensus of the IETF community. It has // received public review and has been approved for publication by the // Internet Engineering Steering Group (IESG). Further information on // Internet Standards is available in Section 2 of RFC 5741. // // Information about the current status of this document, any errata, // and how to provide feedback on it may be obtained at // http://www.rfc-editor.org/info/rfc6265. // // Copyright Notice // // Copyright (c) 2011 IETF Trust and the persons identified as the // document authors. All rights reserved. // // This document is subject to BCP 78 and the IETF Trust's Legal // Provisions Relating to IETF Documents // (http://trustee.ietf.org/license-info) in effect on the date of // publication of this document. Please review these documents // carefully, as they describe your rights and restrictions with respect // to this document. Code Components extracted from this document must // include Simplified BSD License text as described in Section 4.e of // the Trust Legal Provisions and are provided without warranty as // described in the Simplified BSD License. // // This document may contain material from IETF Documents or IETF // Contributions published or made publicly available before November // 10, 2008. The person(s) controlling the copyright in some of this // material may not have granted the IETF Trust the right to allow // modifications of such material outside the IETF Standards Process. // Without obtaining an adequate license from the person(s) controlling // the copyright in such materials, this document may not be modified // outside the IETF Standards Process, and derivative works of it may // not be created outside the IETF Standards Process, except to format // it for publication as an RFC or to translate it into languages other // than English. // // Table of Contents // // 1. Introduction ....................................................3 // 2. Conventions .....................................................4 // 2.1. Conformance Criteria .......................................4 // 2.2. Syntax Notation ............................................5 // 2.3. Terminology ................................................5 // 3. Overview ........................................................6 // 3.1. Examples ...................................................6 // 4. Server Requirements .............................................8 // 4.1. Set-Cookie .................................................8 // 4.1.1. Syntax ..............................................8 // 4.1.2. Semantics (Non-Normative) ..........................10 // 4.2. Cookie ....................................................13 // 4.2.1. Syntax .............................................13 // 4.2.2. Semantics ..........................................13 // 5. User Agent Requirements ........................................14 // 5.1. Subcomponent Algorithms ...................................14 // 5.1.1. Dates ..............................................14 // 5.1.2. Canonicalized Host Names ...........................16 // 5.1.3. Domain Matching ....................................16 // 5.1.4. Paths and Path-Match ...............................16 // 5.2. The Set-Cookie Header .....................................17 // 5.2.1. The Expires Attribute ..............................19 // 5.2.2. The Max-Age Attribute ..............................20 // 5.2.3. The Domain Attribute ...............................20 // 5.2.4. The Path Attribute .................................21 // 5.2.5. The Secure Attribute ...............................21 // 5.2.6. The HttpOnly Attribute .............................21 // 5.3. Storage Model .............................................21 // 5.4. The Cookie Header .........................................25 // 6. Implementation Considerations ..................................27 // 6.1. Limits ....................................................27 // 6.2. Application Programming Interfaces ........................27 // 6.3. IDNA Dependency and Migration .............................27 // 7. Privacy Considerations .........................................28 // // 7.1. Third-Party Cookies .......................................28 // 7.2. User Controls .............................................28 // 7.3. Expiration Dates ..........................................29 // 8. Security Considerations ........................................29 // 8.1. Overview ..................................................29 // 8.2. Ambient Authority .........................................30 // 8.3. Clear Text ................................................30 // 8.4. Session Identifiers .......................................31 // 8.5. Weak Confidentiality ......................................32 // 8.6. Weak Integrity ............................................32 // 8.7. Reliance on DNS ...........................................33 // 9. IANA Considerations ............................................33 // 9.1. Cookie ....................................................34 // 9.2. Set-Cookie ................................................34 // 9.3. Cookie2 ...................................................34 // 9.4. Set-Cookie2 ...............................................34 // 10. References ....................................................35 // 10.1. Normative References .....................................35 // 10.2. Informative References ...................................35 // Appendix A. Acknowledgements ......................................37 // // ===== LITERATURE_SOURCES // * RFC (2023-09-30) // URL: http://www.faqs.org/rfcs/rfc6265.html // RFC_6265_HTTP_STATE_MANAGEMENT_MECHANISM - END // // RFC_2109_HTTP_STATE_MANAGEMENT_MECHANISM - BEGIN // RFC 2109 - HTTP State Management Mechanism // // Network Working Group D. Kristol // Request for Comments: 2109 Bell Laboratories, Lucent Technologies // Category: Standards Track L. Montulli // Netscape Communications // February 1997 // // HTTP State Management Mechanism // // Status of this Memo // // This document specifies an Internet standards track protocol for the // Internet community, and requests discussion and suggestions for // improvements. Please refer to the current edition of the "Internet // Official Protocol Standards" (STD 1) for the standardization state // and status of this protocol. Distribution of this memo is unlimited. // // 1. ABSTRACT // // This document specifies a way to create a stateful session with HTTP // requests and responses. It describes two new headers, Cookie and // Set-Cookie, which carry state information between participating // origin servers and user agents. The method described here differs // from Netscape's Cookie proposal, but it can interoperate with // HTTP/1.0 user agents that use Netscape's method. (See the HISTORICAL // section.) // // 2. TERMINOLOGY // // The terms user agent, client, server, proxy, and origin server have // the same meaning as in the HTTP/1.0 specification. // // Fully-qualified host name (FQHN) means either the fully-qualified // domain name (FQDN) of a host (i.e., a completely specified domain // name ending in a top-level domain such as .com or .uk), or the // numeric Internet Protocol (IP) address of a host. The fully // qualified domain name is preferred; use of numeric IP addresses is // strongly discouraged. // // The terms request-host and request-URI refer to the values the client // would send to the server as, respectively, the host (but not port) // and abs_path portions of the absoluteURI (http_URL) of the HTTP // request line. Note that request-host must be a FQHN. // // Hosts names can be specified either as an IP address or a FQHN // string. Sometimes we compare one host name with another. Host A's // name domain-matches host B's if // // * both host names are IP addresses and their host name strings match // exactly; or // // * both host names are FQDN strings and their host name strings match // exactly; or // // * A is a FQDN string and has the form NB, where N is a non-empty name // string, B has the form .B', and B' is a FQDN string. (So, x.y.com // domain-matches .y.com but not y.com.) // // Note that domain-match is not a commutative operation: a.b.c.com // domain-matches .c.com, but not the reverse. // // Because it was used in Netscape's original implementation of state // management, we will use the term cookie to refer to the state // information that passes between an origin server and user agent, and // that gets stored by the user agent. // // ===== LITERATURE_SOURCES // * RFC (2023-09-22) // URL: http://www.faqs.org/rfcs/rfc2109.html // RFC_2109_HTTP_STATE_MANAGEMENT_MECHANISM - END // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SERVER_VARIABLE // ============================== PUBLIC // ============================== ABOUT // Server and execution environment information. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING VARIABLES (1) // $_SERVER - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_server_variable() { $return_server = null; // ========== _SERVER - BEGIN // ===== ABOUT // Server and execution environment information // ===== DESCRIPTION // $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server, therefore there is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. However, most of these variables are accounted for in the > CGI/1.1 specification, and are likely to be defined. // Note: When running PHP on the command line most of these entries will not be available or have any meaning. // In addition to the elements listed below, PHP will create additional elements with values from request headers. These entries will be named HTTP_ followed by the header name, capitalized and with underscores instead of hyphens. For example, the Accept-Language header would be available as $_SERVER['HTTP_ACCEPT_LANGUAGE']. // // Indices // 'PHP_SELF' - The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/foo/bar.php would be /foo/bar.php. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name. // 'argv' - Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string. // 'argc' - Contains the number of command line parameters passed to the script (if run on the command line). // 'GATEWAY_INTERFACE' - What revision of the CGI specification the server is using; e.g. 'CGI/1.1'. // 'SERVER_ADDR' - The IP address of the server under which the current script is executing. // 'SERVER_NAME' - The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host. // Note: Under Apache 2, UseCanonicalName = On and ServerName must be set. Otherwise, this value reflects the hostname supplied by the client, which can be spoofed. It is not safe to rely on this value in security-dependent contexts. // 'SERVER_SOFTWARE' - Server identification string, given in the headers when responding to requests. // 'SERVER_PROTOCOL' - Name and revision of the information protocol via which the page was requested; e.g. 'HTTP/1.0'; // 'REQUEST_METHOD' - Which request method was used to access the page; e.g. 'GET', 'HEAD', 'POST', 'PUT'. // Note: PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD. // 'REQUEST_TIME' - The timestamp of the start of the request. // 'REQUEST_TIME_FLOAT' - The timestamp of the start of the request, with microsecond precision. // 'QUERY_STRING' - The query string, if any, via which the page was accessed. // 'DOCUMENT_ROOT' - The document root directory under which the current script is executing, as defined in the server's configuration file. // 'HTTPS' - Set to a non-empty value if the script was queried through the HTTPS protocol. // 'REMOTE_ADDR' - The IP address from which the user is viewing the current page. // 'REMOTE_HOST' - The Host name from which the user is viewing the current page. The reverse dns lookup is based on the REMOTE_ADDR of the user. // Note: The web server must be configured to create this variable. For example in Apache HostnameLookups On must be set inside httpd.conf for it to exist. See also gethostbyaddr(). // 'REMOTE_PORT' - The port being used on the user's machine to communicate with the web server. // 'REMOTE_USER' - The authenticated user. // 'REDIRECT_REMOTE_USER' - The authenticated user if the request is internally redirected. // 'SCRIPT_FILENAME' - The absolute pathname of the currently executing script. // Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. // 'SERVER_ADMIN' - The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host. // 'SERVER_PORT' - The port on the server machine being used by the web server for communication. For default setups, this will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is. // Note: Under Apache 2, UseCanonicalName = On, as well as UseCanonicalPhysicalPort = On must be set in order to get the physical (real) port, otherwise, this value can be spoofed, and it may or may not return the physical port value. It is not safe to rely on this value in security-dependent contexts. // 'SERVER_SIGNATURE' - String containing the server version and virtual host name which are added to server-generated pages, if enabled. // 'PATH_TRANSLATED' - Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping. // Note: Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO. // 'SCRIPT_NAME' - Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. // 'REQUEST_URI' - The URI which was given in order to access this page; for instance, '/index.html'. // 'PHP_AUTH_DIGEST' - When doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation). // 'PHP_AUTH_USER' - When doing HTTP authentication this variable is set to the username provided by the user. // 'PHP_AUTH_PW' - When doing HTTP authentication this variable is set to the password provided by the user. // 'AUTH_TYPE' - When doing HTTP authentication this variable is set to the authentication type. // 'PATH_INFO' - Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URI http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff. // 'ORIG_PATH_INFO' - Original version of 'PATH_INFO' before processed by PHP. // ===== SUPPORTED // PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_server = $_SERVER; // [examples] // Examples // [example] // Example #1 $_SERVER example // [php] // echo $_SERVER['SERVER_NAME']; // [/php] // The above example will output something similar to: // [result] // www.example.com // [/result] // [/example] // [/examples] // // Notes // Note: This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/reserved.variables.server.php // ========== _SERVER - END // SYNTAX: // array $_SERVER return $return_server; // array } // ============================== END // PHP_OTHER_NETWORK_SERVER_VARIABLE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_POST_VARIABLE // ============================== PUBLIC // ============================== ABOUT // HTTP POST variables. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING VARIABLES (1) // $_POST - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_post_variable() { $return_post = null; // ========== _POST - BEGIN // ===== ABOUT // HTTP POST variables // ===== DESCRIPTION // An associative array of variables passed to the current script via the HTTP POST method when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request. // ===== SUPPORTED // PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_post = $_POST; // [examples] // Examples // [example] // Example #1 $_POST example // [php] // echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!'; // [/php] // Assuming the user POSTed name=Hannes // The above example will output something similar to: // [result] // Hello Hannes! // [/result] // [/example] // [/examples] // // Notes // Note: This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/reserved.variables.post.php // ========== _POST - END // SYNTAX: // array $_POST return $return_post; // array } // ============================== END // PHP_OTHER_NETWORK_POST_VARIABLE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_REQUEST_VARIABLE // ============================== PUBLIC // ============================== ABOUT // HTTP Request variables. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING VARIABLES (1) // $_REQUEST - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_request_variable() { $return_request = null; // ========== _REQUEST - BEGIN // ===== ABOUT // HTTP Request variables // ===== DESCRIPTION // An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE. // ===== SUPPORTED // PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_request = $_REQUEST; // Notes // Note: This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods. // Note: When running on the command line , this will not include the argv and argc entries; these are present in the $_SERVER array. // Note: The variables in $_REQUEST are provided to the script via the GET, POST, and COOKIE input mechanisms and therefore could be modified by the remote user and cannot be trusted. The presence and order of variables listed in this array is defined according to the PHP request_order, and variables_order configuration directives. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/reserved.variables.request.php // ========== _REQUEST - END // SYNTAX: // array $_REQUEST return $return_request; // array } // ============================== END // PHP_OTHER_NETWORK_REQUEST_VARIABLE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_COOKIE_VARIABLE // ============================== PUBLIC // ============================== ABOUT // HTTP Cookies. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING VARIABLES (1) // $_COOKIE - PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_cookie_variable() { $return_cookie = null; // ========== _COOKIE - BEGIN // ===== ABOUT // HTTP Cookies // ===== DESCRIPTION // An associative array of variables passed to the current script via HTTP Cookies. // ===== SUPPORTED // PHP_4 >= PHP_4_1_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_cookie = $_COOKIE; // [examples] // Examples // [example] // Example #1 $_COOKIE example // [php] // echo 'Hello ' . htmlspecialchars($_COOKIE["name"]) . '!'; // [/php] // Assuming the "name" cookie has been set earlier // The above example will output something similar to: // [result] // Hello Hannes! // [/result] // [/example] // [/examples] // // Notes // Note: This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/reserved.variables.cookies.php // ========== _COOKIE - END // array $_COOKIE return $return_cookie; // array } // ============================== END // PHP_OTHER_NETWORK_COOKIE_VARIABLE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HTTP_RESPONSE_HEADER_VARIABLE // ============================== PUBLIC // ============================== ABOUT // HTTP response headers. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING VARIABLES (1) // $http_response_header - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_http_response_header_variable() { $return_http_response_header = null; // ========== HTTP_RESPONSE_HEADER - BEGIN // ===== ABOUT // HTTP response headers // ===== DESCRIPTION // The $http_response_header array is similar to the get_headers() function. When using the HTTP wrapper, $http_response_header will be populated with the HTTP response headers. $http_response_header will be created in the local scope. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_http_response_header = $http_response_header; // [examples] // Examples // [example] // Example #1 $http_response_header example // [php] // function get_contents() { // file_get_contents("http://example.com"); // var_dump($http_response_header); // variable is populated in the local scope // } // get_contents(); // var_dump($http_response_header); // a call to get_contents() does not populate the variable outside the function scope // [/php] // The above example will output something similar to: // [result] // array(9) { // [0]=> // string(15) "HTTP/1.1 200 OK" // [1]=> // string(35) "Date: Sat, 12 Apr 2008 17:30:38 GMT" // [2]=> // string(29) "Server: Apache/2.2.3 (CentOS)" // [3]=> // string(44) "Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT" // [4]=> // string(27) "ETag: "280100-1b6-80bfd280"" // [5]=> // string(20) "Accept-Ranges: bytes" // [6]=> // string(19) "Content-Length: 438" // [7]=> // string(17) "Connection: close" // [8]=> // string(38) "Content-Type: text/html; charset=UTF-8" // } // // Warning: Undefined variable $http_response_header // NULL // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/reserved.variables.httpresponseheader.php // ========== HTTP_RESPONSE_HEADER - END // SYNTAX: // array $http_response_header return $return_http_response_header; // array } // ============================== END // PHP_OTHER_NETWORK_HTTP_RESPONSE_HEADER_VARIABLE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_CHECKDNSRR // ============================== PUBLIC // ============================== ABOUT // Check DNS records corresponding to a given Internet host name or IP address. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // checkdnsrr() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_checkdnsrr($hostname, $type = "MX") { $return_checkdnsrr = false; // ========== CHECKDNSRR - BEGIN // ===== ABOUT // Check DNS records corresponding to a given Internet host name or IP address // ===== DESCRIPTION // Searches DNS for records of type type corresponding to hostname. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // checkdnsrr(string $hostname, string $type = "MX"): bool // ===== CODE $return_checkdnsrr = checkdnsrr( $hostname, // string hostname - hostname may either be the IP address in dotted-quad notation or the host name. $type // string type - type may be any one of: A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY. ); // Return Values // Returns true if any records are found; returns false if no records were found or if an error occurred. // // Notes // Note: For compatibility with Windows before this was implemented, then try the > PEAR class > Net_DNS. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/function.checkdnsrr.php // ========== CHECKDNSRR - END // SYNTAX: // bool checkdnsrr(string $hostname, string $type = "MX") return $return_checkdnsrr; // bool } // ============================== END // PHP_OTHER_NETWORK_CHECKDNSRR // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_CLOSELOG // ============================== PUBLIC // ============================== ABOUT // Close connection to system logger. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // closelog() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_closelog() { $return_closelog = false; // ========== CLOSELOG - BEGIN // ===== ABOUT // Close connection to system logger // ===== DESCRIPTION // closelog() closes the descriptor being used to write to the system logger. The use of closelog() is optional. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // closelog(): true // ===== CODE $return_closelog = closelog( // This function has no parameters. ); // Return Values // Always returns true. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.closelog.php // ========== CLOSELOG - END // SYNTAX: // bool closelog() return $return_closelog; // bool } // ============================== END // PHP_OTHER_NETWORK_CLOSELOG // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_DNS_CHECK_RECORD // ============================== OFFLINE // ============================== ABOUT // Check DNS records corresponding to a given Internet host name or IP address. // // dns_check_record - Alias of checkdnsrr(). // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // dns_check_record() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_dns_check_record($hostname, $type = "MX") { $return_dns_check_record = false; // ========== DNS_CHECK_RECORD - BEGIN // ===== ABOUT // dns_check_record - Alias of checkdnsrr() // ===== DESCRIPTION // This function is an alias of: checkdnsrr(). // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_dns_check_record = dns_check_record( $hostname, // string hostname $type // string type ); // Return // bool // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/function.dns-check-record.php // ========== DNS_CHECK_RECORD - END // ========== CHECKDNSRR - BEGIN // ===== ABOUT // Check DNS records corresponding to a given Internet host name or IP address // ===== DESCRIPTION // Searches DNS for records of type type corresponding to hostname. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // checkdnsrr(string $hostname, string $type = "MX"): bool // ===== CODE // $return_checkdnsrr = checkdnsrr( // $hostname, // string hostname - hostname may either be the IP address in dotted-quad notation or the host name. // $type // string type - type may be any one of: A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY. // ); // Return Values // Returns true if any records are found; returns false if no records were found or if an error occurred. // // Notes // Note: For compatibility with Windows before this was implemented, then try the > PEAR class > Net_DNS. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/function.checkdnsrr.php // ========== CHECKDNSRR - END // SYNTAX: // bool dns_check_record(string $hostname, string $type = "MX") return $return_dns_check_record; // bool } */ // ============================== END // PHP_OTHER_NETWORK_DNS_CHECK_RECORD // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_DNS_GET_MX // ============================== OFFLINE // ============================== ABOUT // Get MX records corresponding to a given Internet host name. // // dns_get_mx - Alias of getmxrr(). // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // dns_get_mx() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_dns_get_mx($hostname, & $hosts, & $weights) { $return_dns_get_mx = false; // ========== DNS_GET_MX - BEGIN // ===== ABOUT // dns_get_mx - Alias of getmxrr() // ===== DESCRIPTION // This function is an alias of: getmxrr(). // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_dns_get_mx = dns_get_mx( $hostname, // string hostname $hosts, // array& hosts $weights // array& weights ); // Return // bool // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/function.dns-get-mx.php // ========== DNS_GET_MX - END // ========== GETMXRR - BEGIN // ===== ABOUT // Get MX records corresponding to a given Internet host name // ===== DESCRIPTION // Searches DNS for MX records corresponding to hostname. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // getmxrr(string $hostname, array &$hosts, array &$weights = null): bool // ===== CODE // $return_getmxrr = getmxrr( // $hostname, // string hostname - The Internet host name. // $hosts, // array& hosts - A list of the MX records found is placed into the array hosts. // $weights // array& weights - If the weights array is given, it will be filled with the weight information gathered. // ); // Return Values // Returns true if any records are found; returns false if no records were found or if an error occurred. // // Notes // Note: This function should not be used for the purposes of address verification. Only the mailexchangers found in DNS are returned, however, according to > RFC 2821 when no mail exchangers are listed, hostname itself should be used as the only mail exchanger with a priority of 0. // Note: For compatibility with Windows before this was implemented, then try the > PEAR class > Net_DNS. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.getmxrr.php // ========== GETMXRR - END // SYNTAX: // bool dns_get_mx(string $hostname, array& $hosts, array& $weights) return $return_dns_get_mx; // bool } */ // ============================== END // PHP_OTHER_NETWORK_DNS_GET_MX // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_DNS_GET_RECORD // ============================== OFFLINE // ============================== ABOUT // Fetch DNS Resource Records associated with a hostname. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // dns_get_record() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_dns_get_record($hostname, $type, & $authoritative_name_servers, & $additional_records, $raw) { $return_dns_get_record = false; // ========== DNS_GET_RECORD - BEGIN // ===== ABOUT // Fetch DNS Resource Records associated with a hostname // ===== DESCRIPTION // Fetch DNS Resource Records associated with the given hostname. // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // dns_get_record( // string $hostname, // int $type = DNS_ANY, // array &$authoritative_name_servers = null, // array &$additional_records = null, // bool $raw = false // ): array|false // ===== CODE $return_dns_get_record = dns_get_record( $hostname, // string hostname - hostname should be a valid DNS hostname such as "www.example.com". Reverse lookups can be generated using in-addr.arpa notation, but gethostbyaddr() is more suitable for the majority of reverse lookups. // Note: Per DNS standards, email addresses are given in user.host format (for example: hostmaster.example.com as opposed to hostmaster@example.com), be sure to check this value and modify if necessary before using it with a functions such as mail(). $type, // int type - By default, dns_get_record() will search for any resource records associated with hostname. To limit the query, specify the optional type parameter. May be any one of the following: DNS_A, DNS_CNAME, DNS_HINFO, DNS_CAA, DNS_MX, DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_SRV, DNS_NAPTR, DNS_A6, DNS_ALL or DNS_ANY. // Note: Because of eccentricities in the performance of libresolv between platforms, DNS_ANY will not always return every record, the slower DNS_ALL will collect all records more reliably. // Note: Windows: DNS_CAA is not supported. Support for DNS_A6 is not implemented. $authoritative_name_servers, // array& authoritative_name_servers - Passed by reference and, if given, will be populated with Resource Records for the Authoritative Name Servers. $additional_records, // array& additional_records - Passed by reference and, if given, will be populated with any Additional Records. $raw // bool raw - The type will be interpreted as a raw DNS type ID (the DNS_* constants cannot be used). The return value will contain a data key, which needs to be manually parsed. ); // Return Values // This function returns an array of associative arrays, or false on failure. Each associative array contains at minimum the following keys: // Basic DNS attributes // Attribute - Meaning // host - The record in the DNS namespace to which the rest of the associated data refers. // class - dns_get_record() only returns Internet class records and as such this parameter will always return IN. // type - String containing the record type. Additional attributes will also be contained in the resulting array dependant on the value of type. See table below. // ttl - "Time To Live" remaining for this record. This will not equal the record's original ttl, but will rather equal the original ttl minus whatever length of time has passed since the authoritative name server was queried. // Other keys in associative arrays dependant on 'type' // Type - Extra Columns // A - ip: An IPv4 addresses in dotted decimal notation. // MX - pri: Priority of mail exchanger. Lower numbers indicate greater priority. target: FQDN of the mail exchanger. See also dns_get_mx(). // CNAME - target: FQDN of location in DNS namespace to which the record is aliased. // NS - target: FQDN of the name server which is authoritative for this hostname. // PTR - target: Location within the DNS namespace to which this record points. // TXT - txt: Arbitrary string data associated with this record. // HINFO - cpu: IANA number designating the CPU of the machine referenced by this record. os: IANA number designating the Operating System on the machine referenced by this record. See IANA's > Operating System Names for the meaning of these values. // CAA - flags: A one-byte bitfield; currently only bit 0 is defined, meaning 'critical'; other bits are reserved and should be ignored. tag: The CAA tag name (alphanumeric ASCII string). value: The CAA tag value (binary string, may use subformats). For additional information see: > RFC 6844 // SOA - mname: FQDN of the machine from which the resource records originated. rname: Email address of the administrative contact for this domain. serial: Serial # of this revision of the requested domain. refresh: Refresh interval (seconds) secondary name servers should use when updating remote copies of this domain. retry: Length of time (seconds) to wait after a failed refresh before making a second attempt. expire: Maximum length of time (seconds) a secondary DNS server should retain remote copies of the zone data without a successful refresh before discarding. minimum-ttl: Minimum length of time (seconds) a client can continue to use a DNS resolution before it should request a new resolution from the server. Can be overridden by individual resource records. // AAAA - ipv6: IPv6 address // A6 - masklen: Length (in bits) to inherit from the target specified by chain. ipv6: Address for this specific record to merge with chain. chain: Parent record to merge with ipv6 data. // SRV - pri: (Priority) lowest priorities should be used first. weight: Ranking to weight which of commonly prioritized targets should be chosen at random. target and port: hostname and port where the requested service can be found. For additional information see: > RFC 2782 // NAPTR - order and pref: Equivalent to pri and weight above. flags, services, regex, and replacement: Parameters as defined by > RFC 2915. // // Changelog // Version - Description // 7.0.16, 7.1.2 - Added support for CAA record type. // // [examples] // Examples // [example] // Example #1 Using dns_get_record() // [php] // $result = dns_get_record("php.net"); // print_r($result); // [/php] // The above example will output something similar to: // [result] // Array // ( // [0] => Array // ( // [host] => php.net // [type] => MX // [pri] => 5 // [target] => pair2.php.net // [class] => IN // [ttl] => 6765 // ) // // [1] => Array // ( // [host] => php.net // [type] => A // [ip] => 64.246.30.37 // [class] => IN // [ttl] => 8125 // ) // // ) // [/result] // [/example] // [example] // Example #2 Using dns_get_record() and DNS_ANY // Since it's very common to want the IP address of a mail server once the MX record has been resolved, dns_get_record() also returns an array in additional_records which contains associate records. authoritative_name_servers is returned as well containing a list of authoritative name servers. // [php] // // Request "ANY" record for php.net, // // and create $authns and $addtl arrays // // containing list of name servers and // // any additional records which go with // // them // $result = dns_get_record("php.net", DNS_ANY, $authns, $addtl); // echo "Result = "; // print_r($result); // echo "Auth NS = "; // print_r($authns); // echo "Additional = "; // print_r($addtl); // [/php] // The above example will output something similar to: // [result] // Result = Array // ( // [0] => Array // ( // [host] => php.net // [type] => MX // [pri] => 5 // [target] => pair2.php.net // [class] => IN // [ttl] => 6765 // ) // // [1] => Array // ( // [host] => php.net // [type] => A // [ip] => 64.246.30.37 // [class] => IN // [ttl] => 8125 // ) // // ) // Auth NS = Array // ( // [0] => Array // ( // [host] => php.net // [type] => NS // [target] => remote1.easydns.com // [class] => IN // [ttl] => 10722 // ) // // [1] => Array // ( // [host] => php.net // [type] => NS // [target] => remote2.easydns.com // [class] => IN // [ttl] => 10722 // ) // // [2] => Array // ( // [host] => php.net // [type] => NS // [target] => ns1.easydns.com // [class] => IN // [ttl] => 10722 // ) // // [3] => Array // ( // [host] => php.net // [type] => NS // [target] => ns2.easydns.com // [class] => IN // [ttl] => 10722 // ) // // ) // Additional = Array // ( // [0] => Array // ( // [host] => pair2.php.net // [type] => A // [ip] => 216.92.131.5 // [class] => IN // [ttl] => 6766 // ) // // [1] => Array // ( // [host] => remote1.easydns.com // [type] => A // [ip] => 64.39.29.212 // [class] => IN // [ttl] => 100384 // ) // // [2] => Array // ( // [host] => remote2.easydns.com // [type] => A // [ip] => 212.100.224.80 // [class] => IN // [ttl] => 81241 // ) // // [3] => Array // ( // [host] => ns1.easydns.com // [type] => A // [ip] => 216.220.40.243 // [class] => IN // [ttl] => 81241 // ) // // [4] => Array // ( // [host] => ns2.easydns.com // [type] => A // [ip] => 216.220.40.244 // [class] => IN // [ttl] => 81241 // ) // // ) // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/function.dns-get-record.php // ========== DNS_GET_RECORD - END // SYNTAX: // array|false dns_get_record(string $hostname, int $type, array& $authoritative_name_servers, array& $additional_records, bool $raw) return $return_dns_get_record; // array|false } */ // ============================== END // PHP_OTHER_NETWORK_DNS_GET_RECORD // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_FSOCKOPEN // ============================== PUBLIC // ============================== ABOUT // Open Internet or Unix domain socket connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // fsockopen() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_fsockopen($hostname, $port, & $error_code, & $error_message, $timeout) { $return_fsockopen = false; // ========== FSOCKOPEN - BEGIN // ===== ABOUT // Open Internet or Unix domain socket connection // ===== DESCRIPTION // Initiates a socket connection to the resource specified by hostname. // PHP supports targets in the Internet and Unix domains as described in List of Supported Socket Transports. A list of supported transports can also be retrieved using stream_get_transports(). // The socket will by default be opened in blocking mode. You can switch it to non-blocking mode by using stream_set_blocking(). // The function stream_socket_client() is similar but provides a richer set of options, including non-blocking connection and the ability to provide a stream context. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // fsockopen( // string $hostname, // int $port = -1, // int &$error_code = null, // string &$error_message = null, // ?float $timeout = null // ): resource|false // ===== CODE $return_fsockopen = fsockopen( $hostname, // string hostname - If OpenSSL support is installed, you may prefix the hostname with either ssl:// or tls:// to use an SSL or TLS client connection over TCP/IP to connect to the remote host. $port, // int port - The port number. This can be omitted and skipped with -1 for transports that do not use ports, such as unix://. $error_code, // int& error_code - If provided, holds the system level error number that occurred in the system-level connect() call. // If the value returned in error_code is 0 and the function returned false, it is an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket. $error_message, // string& error_message - The error message as a string. $timeout // float timeout - The connection timeout, in seconds. When null, the default_socket_timeout php.ini setting is used. // Note: If you need to set a timeout for reading/writing data over the socket, use stream_set_timeout(), as the timeout parameter to fsockopen() only applies while connecting the socket. ); // Return Values // fsockopen() returns a file pointer which may be used together with the other file functions (such as fgets(), fgetss(), fwrite(), fclose(), and feof()). If the call fails, it will return false // // Errors/Exceptions // Throws E_WARNING if hostname is not a valid domain. // // Changelog // Version - Description // 8.0.0 - timeout is nullable now. // // [examples] // Examples // [example] // Example #1 fsockopen() Example // [php] // $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30); // if (!$fp) { // echo "$errstr ($errno)
\n"; // } else { // $out = "GET / HTTP/1.1\r\n"; // $out .= "Host: www.example.com\r\n"; // $out .= "Connection: Close\r\n\r\n"; // fwrite($fp, $out); // while (!feof($fp)) { // echo fgets($fp, 128); // } // fclose($fp); // } // [/php] // [/example] // [example] // Example #2 Using UDP connection // The example below shows how to retrieve the day and time from the UDP service "daytime" (port 13) in your own machine. // [php] // $fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr); // if (!$fp) { // echo "ERROR: $errno - $errstr
\n"; // } else { // fwrite($fp, "\n"); // echo fread($fp, 26); // fclose($fp); // } // [/php] // [/example] // [/examples] // // Notes // Note: Depending on the environment, the Unix domain or the optional connect timeout may not be available. // Warning: UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data. // Note: When specifying a numerical IPv6 address (e.g. fe80::1), you must enclose the IP in square brackets-for example, tcp://[fe80::1]:80. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.fsockopen.php // ========== FSOCKOPEN - END // SYNTAX: // resource|false fsockopen(string $hostname, int $port = -1, int& $error_code = null, string& $error_message = null, float $timeout = null) return $return_fsockopen; // resource|false } // ============================== END // PHP_OTHER_NETWORK_FSOCKOPEN // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETHOSTBYADDR // ============================== PUBLIC // ============================== ABOUT // Get the Internet host name corresponding to a given IP address. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // gethostbyaddr() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_gethostbyaddr($ip) { $return_gethostbyaddr = false; // ========== GETHOSTBYADDR - BEGIN // ===== ABOUT // Get the Internet host name corresponding to a given IP address // ===== DESCRIPTION // Returns the host name of the Internet host specified by ip. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // gethostbyaddr(string $ip): string|false // ===== CODE $return_gethostbyaddr = gethostbyaddr( $ip // string ip - The host IP address. ); // Return Values // Returns the host name on success, the unmodified ip on failure, or false on malformed input. // // [examples] // Examples // [example] // Example #1 A simple gethostbyaddr() example // [php] // $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); // // echo $hostname; // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.gethostbyaddr.php // ========== GETHOSTBYADDR - END // SYNTAX: // string|false gethostbyaddr(string $ip) return $return_gethostbyaddr; // string|false } // ============================== END // PHP_OTHER_NETWORK_GETHOSTBYADDR // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETHOSTBYNAME // ============================== PUBLIC // ============================== ABOUT // Get the IPv4 address corresponding to a given Internet host name. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // gethostbyname() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_gethostbyname($hostname) { $return_gethostbyname = null; // ========== GETHOSTBYNAME - BEGIN // ===== ABOUT // Get the IPv4 address corresponding to a given Internet host name // ===== DESCRIPTION // Returns the IPv4 address of the Internet host specified by hostname. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // gethostbyname(string $hostname): string // ===== CODE $return_gethostbyname = gethostbyname( $hostname // string hostname - The host name. ); // Return Values // Returns the IPv4 address or a string containing the unmodified hostname on failure. // // [examples] // Examples // [example] // Example #1 A simple gethostbyname() example // [php] // $ip = gethostbyname('www.example.com'); // // echo $ip; // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.gethostbyname.php // ========== GETHOSTBYNAME - END // SYNTAX: // string gethostbyname(string $hostname) return $return_gethostbyname; // string } // ============================== END // PHP_OTHER_NETWORK_GETHOSTBYNAME // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETHOSTBYNAMEL // ============================== PUBLIC // ============================== ABOUT // Get a list of IPv4 addresses corresponding to a given Internet host name. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // gethostbynamel() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_gethostbynamel($hostname) { $return_gethostbynamel = false; // ========== GETHOSTBYNAMEL - BEGIN // ===== ABOUT // Get a list of IPv4 addresses corresponding to a given Internet host name // ===== DESCRIPTION // Returns a list of IPv4 addresses to which the Internet host specified by hostname resolves. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // gethostbynamel(string $hostname): array|false // ===== CODE $return_gethostbynamel = gethostbynamel( $hostname // string hostname - The host name. ); // Return Values // Returns an array of IPv4 addresses or false if hostname could not be resolved. // // [examples] // Examples // [example] // Example #1 gethostbynamel() example // [php] // $hosts = gethostbynamel('www.example.com'); // print_r($hosts); // [/php] // The above example will output: // [result] // Array // ( // [0] => 192.0.34.166 // ) // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.gethostbynamel.php // ========== GETHOSTBYNAMEL - END // SYNTAX: // array|false gethostbynamel(string $hostname) return $return_gethostbynamel; // array|false } // ============================== END // PHP_OTHER_NETWORK_GETHOSTBYNAMEL // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETHOSTNAME // ============================== OFFLINE // ============================== ABOUT // Gets the host name. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // gethostname() - PHP_5 >= PHP_5_3_0, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_gethostname() { $return_gethostname = false; // ========== GETHOSTNAME - BEGIN // ===== ABOUT // Gets the host name // ===== DESCRIPTION // gethostname() gets the standard host name for the local machine. // ===== SUPPORTED // PHP_5 >= PHP_5_3_0, PHP_7, PHP_8 // ===== SYNTAX // gethostname(): string|false // ===== CODE $return_gethostname = gethostname( // This function has no parameters. ); // Return Values // Returns a string with the hostname on success, otherwise false is returned. // // [examples] // Examples // [example] // Example #1 A simple gethostname() example // [php] // echo gethostname(); // may output e.g,: sandie // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.gethostname.php // ========== GETHOSTNAME - END // SYNTAX: // string|false gethostname() return $return_gethostname; // string|false } */ // ============================== END // PHP_OTHER_NETWORK_GETHOSTNAME // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETMXRR // ============================== PUBLIC // ============================== ABOUT // Get MX records corresponding to a given Internet host name. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // getmxrr() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_getmxrr($hostname, & $hosts, & $weights) { $return_getmxrr = false; // ========== GETMXRR - BEGIN // ===== ABOUT // Get MX records corresponding to a given Internet host name // ===== DESCRIPTION // Searches DNS for MX records corresponding to hostname. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // getmxrr(string $hostname, array &$hosts, array &$weights = null): bool // ===== CODE $return_getmxrr = getmxrr( $hostname, // string hostname - The Internet host name. $hosts, // array& hosts - A list of the MX records found is placed into the array hosts. $weights // array& weights - If the weights array is given, it will be filled with the weight information gathered. ); // Return Values // Returns true if any records are found; returns false if no records were found or if an error occurred. // // Notes // Note: This function should not be used for the purposes of address verification. Only the mailexchangers found in DNS are returned, however, according to > RFC 2821 when no mail exchangers are listed, hostname itself should be used as the only mail exchanger with a priority of 0. // Note: For compatibility with Windows before this was implemented, then try the > PEAR class > Net_DNS. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.getmxrr.php // ========== GETMXRR - END // SYNTAX: // bool getmxrr(string $hostname, array& $hosts, array& $weights) return $return_getmxrr; // bool } // ============================== END // PHP_OTHER_NETWORK_GETMXRR // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETPROTOBYNAME // ============================== PUBLIC // ============================== ABOUT // Get protocol number associated with protocol name. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // getprotobyname() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_getprotobyname($protocol) { $return_getprotobyname = false; // ========== GETPROTOBYNAME - BEGIN // ===== ABOUT // Get protocol number associated with protocol name // ===== DESCRIPTION // getprotobyname() returns the protocol number associated with the protocol protocol as per /etc/protocols. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // getprotobyname(string $protocol): int|false // ===== CODE $return_getprotobyname = getprotobyname( $protocol // string protocol - The protocol name. ); // Return Values // Returns the protocol number, or false on failure. // // [examples] // Examples // [example] // Example #1 getprotobyname() example // [php] // $protocol = 'tcp'; // $get_prot = getprotobyname($protocol); // if ($get_prot === FALSE) { // echo 'Invalid Protocol'; // } else { // echo 'Protocol #' . $get_prot; // } // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.getprotobyname.php // ========== GETPROTOBYNAME - END // SYNTAX: // int|false getprotobyname(string $protocol) return $return_getprotobyname; // int|false } // ============================== END // PHP_OTHER_NETWORK_GETPROTOBYNAME // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETPROTOBYNUMBER // ============================== PUBLIC // ============================== ABOUT // Get protocol name associated with protocol number. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // getprotobynumber() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_getprotobynumber($protocol) { $return_getprotobynumber = false; // ========== GETPROTOBYNUMBER - BEGIN // ===== ABOUT // Get protocol name associated with protocol number // ===== DESCRIPTION // getprotobynumber() returns the protocol name associated with protocol protocol as per /etc/protocols. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // getprotobynumber(int $protocol): string|false // ===== CODE $return_getprotobynumber = getprotobynumber( $protocol // int protocol - The protocol number. ); // Return Values // Returns the protocol name as a string, or false on failure. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.getprotobynumber.php // ========== GETPROTOBYNUMBER - END // SYNTAX: // string|false getprotobynumber(int $protocol) return $return_getprotobynumber; // string|false } // ============================== END // PHP_OTHER_NETWORK_GETPROTOBYNUMBER // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETSERVBYNAME // ============================== PUBLIC // ============================== ABOUT // Get port number associated with an Internet service and protocol. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // getservbyname() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_getservbyname($service, $protocol) { $return_getservbyname = false; // ========== GETSERVBYNAME - BEGIN // ===== ABOUT // Get port number associated with an Internet service and protocol // ===== DESCRIPTION // getservbyname() returns the Internet port which corresponds to service for the specified protocol as per /etc/services. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // getservbyname(string $service, string $protocol): int|false // ===== CODE $return_getservbyname = getservbyname( $service, // string service - The Internet service name, as a string. $protocol // string protocol - protocol is either "tcp" or "udp" (in lowercase). ); // Return Values // Returns the port number, or false if service or protocol is not found. // // [examples] // Examples // [example] // Example #1 getservbyname() example // [php] // $services = array('http', 'ftp', 'ssh', 'telnet', 'imap', // 'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www'); // // foreach ($services as $service) { // $port = getservbyname($service, 'tcp'); // echo $service . ": " . $port . "
\n"; // } // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.getservbyname.php // ========== GETSERVBYNAME - END // SYNTAX: // int|false getservbyname(string $service, string $protocol) return $return_getservbyname; // int|false } // ============================== END // PHP_OTHER_NETWORK_GETSERVBYNAME // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_GETSERVBYPORT // ============================== PUBLIC // ============================== ABOUT // Get Internet service which corresponds to port and protocol. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // getservbyport() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_getservbyport($port, $protocol) { $return_getservbyport = false; // ========== GETSERVBYPORT - BEGIN // ===== ABOUT // Get Internet service which corresponds to port and protocol // ===== DESCRIPTION // getservbyport() returns the Internet service associated with port for the specified protocol as per /etc/services. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // getservbyport(int $port, string $protocol): string|false // ===== CODE $return_getservbyport = getservbyport( $port, // int port - The port number. $protocol // string protocol - protocol is either "tcp" or "udp" (in lowercase). ); // Return Values // Returns the Internet service name as a string, or false on failure. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.getservbyport.php // ========== GETSERVBYPORT - END // SYNTAX: // string|false getservbyport(int $port, string $protocol) return $return_getservbyport; // string|false } // ============================== END // PHP_OTHER_NETWORK_GETSERVBYPORT // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HEADER_REGISTER_CALLBACK // ============================== OFFLINE // ============================== ABOUT // Call a header function. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // header_register_callback() - PHP_5 >= PHP_5_4_0, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_header_register_callback($callback) { $return_header_register_callback = false; // ========== HEADER_REGISTER_CALLBACK - BEGIN // ===== ABOUT // Call a header function // ===== DESCRIPTION // Registers a function that will be called when PHP starts sending output. // The callback is executed just after PHP prepares all headers to be sent, and before any other output is sent, creating a window to manipulate the outgoing headers before being sent. // ===== SUPPORTED // PHP_5 >= PHP_5_4_0, PHP_7, PHP_8 // ===== SYNTAX // header_register_callback(callable $callback): bool // ===== CODE $return_header_register_callback = header_register_callback( $callback // callable callback - Function called just before the headers are sent. It gets no parameters and the return value is ignored. ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 header_register_callback() example // [php] // // header('Content-Type: text/plain'); // header('X-Test: foo'); // // function foo() { // foreach (headers_list() as $header) { // if (strpos($header, 'X-Powered-By:') !== false) { // header_remove('X-Powered-By'); // } // header_remove('X-Test'); // } // } // // $result = header_register_callback('foo'); // echo "a"; // [/php] // The above example will output something similar to: // [result] // Content-Type: text/plain // // a // [/result] // [/example] // [/examples] // // Notes // header_register_callback() is executed just as the headers are about to be sent out, so any output from this function can break output. // Note: Headers will only be accessible and output when a SAPI that supports them is in use. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.header-register-callback.php // ========== HEADER_REGISTER_CALLBACK - END // SYNTAX: // bool header_register_callback(callable $callback) return $return_header_register_callback; // bool } */ // ============================== END // PHP_OTHER_NETWORK_HEADER_REGISTER_CALLBACK // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HEADER_REMOVE // ============================== OFFLINE // ============================== ABOUT // Remove previously set headers. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // header_remove() - PHP_5 >= PHP_5_3_0, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_header_remove($name = null) { // ========== HEADER_REMOVE - BEGIN // ===== ABOUT // Remove previously set headers // ===== DESCRIPTION // Removes an HTTP header previously set using header(). // ===== SUPPORTED // PHP_5 >= PHP_5_3_0, PHP_7, PHP_8 // ===== SYNTAX // header_remove(?string $name = null): void // ===== CODE header_remove( $name // string name - The header name to be removed. When null, all previously set headers are removed. // Note: This parameter is case-insensitive. ); // Return Values // No value is returned. // // Changelog // Version - Description // 8.0.0 - name is nullable now. // // [examples] // Examples // [example] // Example #1 Unsetting specific header. // [php] // header("X-Foo: Bar"); // header("X-Bar: Baz"); // header_remove("X-Foo"); // [/php] // The above example will output something similar to: // [result] // X-Bar: Baz // [/result] // [/example] // [example] // Example #2 Unsetting all previously set headers. // [php] // header("X-Foo: Bar"); // header("X-Bar: Baz"); // header_remove(); // [/php] // The above example will output something similar to: // [result] // [/result] // [/example] // [/examples] // // Notes // Caution: This function will remove all headers set by PHP, including cookies, session and the X-Powered-By headers. // Note: Headers will only be accessible and output when a SAPI that supports them is in use. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.header-remove.php // ========== HEADER_REMOVE - END // SYNTAX: // void header_remove(string $name = null) // Return: void } */ // ============================== END // PHP_OTHER_NETWORK_HEADER_REMOVE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HEADER // ============================== PUBLIC // ============================== ABOUT // Send a raw HTTP header. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // header() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_header($header, $replace = true, $response_code = 0) { // ========== HEADER - BEGIN // ===== ABOUT // Send a raw HTTP header // ===== DESCRIPTION // header() is used to send a raw HTTP header. See the > HTTP/1.1 specification for more information on HTTP headers. // Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. // [code] // // [php] // /* This will give an error. Note the output // * above, which is before the header() call */ // header('Location: http://www.example.com/'); // exit; // [/php] // [/code] // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // header(string $header, bool $replace = true, int $response_code = 0): void // ===== CODE header( $header, // string header - The header string. // There are two special-case header calls. The first is a header that starts with the string "HTTP/" (case is not significant), which will be used to figure out the HTTP status code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive), you may want to make sure that your script generates the proper status code. // [php] // // This example illustrates the "HTTP/" special case // // Better alternatives in typical use cases include: // // 1. header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); // // (to override http status messages for clients that are still using HTTP/1.0) // // 2. http_response_code(404); (to use the default message) // header("HTTP/1.1 404 Not Found"); // [/php] // The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set. // [php] // header("Location: http://www.example.com/"); // Redirect browser // // // Make sure that code below does not get executed when we redirect. // exit; // [/php] $replace, // bool replace - The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in false as the second argument you can force multiple headers of the same type. For example: // [php] // header('WWW-Authenticate: Negotiate'); // header('WWW-Authenticate: NTLM', false); // [/php] $response_code // int response_code - Forces the HTTP response code to the specified value. Note that this parameter only has an effect if the header is not empty. ); // Return Values // No value is returned. // // Errors/Exceptions // On failure to schedule the header to be sent, header() issues an E_WARNING level error. // // [examples] // Examples // [example] // Example #1 Download dialog // If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the > Content-Disposition header to supply a recommended filename and force the browser to display the save dialog. // [php] // // We'll be outputting a PDF // header('Content-Type: application/pdf'); // // // It will be called downloaded.pdf // header('Content-Disposition: attachment; filename="downloaded.pdf"'); // // // The PDF source is in original.pdf // readfile('original.pdf'); // [/php] // [/example] // [example] // Example #2 Caching directives // PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with: // [php] // header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 // header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past // [/php] // Note: // You may find that your pages aren't cached even if you don't output all of the headers above. There are a number of options that users may be able to set for their browser that change its default caching behavior. By sending the headers above, you should override any settings that may otherwise cause the output of your script to be cached. // Additionally, session_cache_limiter() and the session.cache_limiter configuration setting can be used to automatically generate the correct caching-related headers when sessions are being used. // [/example] // [/examples] // // Notes // Note: Headers will only be accessible and output when a SAPI that supports them is in use. // Note: You can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files. // Note: The HTTP status header line will always be the first sent to the client, regardless of the actual header() call being the first or not. The status may be overridden by calling header() with a new status line at any time unless the HTTP headers have already been sent. // Note: // Most contemporary clients accept relative URIs as argument to > Location:, but some older clients require an absolute URI including the scheme, hostname and absolute path. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself: // [php] // // Redirect to a different page in the current directory that was requested // $host = $_SERVER['HTTP_HOST']; // $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); // $extra = 'mypage.php'; // header("Location: http://$host$uri/$extra"); // exit; // [/php] // Note: Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.header.php // ========== HEADER - END // SYNTAX: // void header(string $header, bool $replace = true, int $response_code = 0) // Return: void } // ============================== END // PHP_OTHER_NETWORK_HEADER // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HEADERS_LIST // ============================== OFFLINE // ============================== ABOUT // Returns a list of response headers sent (or ready to send). // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // headers_list() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_headers_list() { $return_headers_list = null; // ========== HEADERS_LIST - BEGIN // ===== ABOUT // Returns a list of response headers sent (or ready to send) // ===== DESCRIPTION // headers_list() will return a list of headers to be sent to the browser / client. To determine whether or not these headers have been sent yet, use headers_sent(). // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // headers_list(): array // ===== CODE $return_headers_list = headers_list( // This function has no parameters. ); // Return Values // Returns a numerically indexed array of headers. // // [examples] // Examples // [example] // Example #1 Example using headers_list() // [php] // // // setcookie() will add a response header on its own // setcookie('foo', 'bar'); // // // Define a custom response header // // This will be ignored by most clients // header("Example-Test: foo"); // // // Specify plain text content in our response // header('Content-Type: text/plain; charset=UTF-8'); // // // What headers are going to be sent? // var_dump(headers_list()); // // [/php] // The above example will output something similar to: // [result] // array(3) { // [0]=> // string(19) "Set-Cookie: foo=bar" // [1]=> // string(17) "Example-Test: foo" // [2]=> // string(39) "Content-Type: text/plain; charset=UTF-8" // } // // [/result] // [/example] // [/examples] // // Notes // Note: Headers will only be accessible and output when a SAPI that supports them is in use. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.headers-list.php // ========== HEADERS_LIST - END // SYNTAX: // array headers_list() return $return_headers_list; // array } */ // ============================== END // PHP_OTHER_NETWORK_HEADERS_LIST // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HEADERS_SENT // ============================== PUBLIC // ============================== ABOUT // Checks if or where headers have been sent. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // headers_sent() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_headers_sent(& $filename, & $line) { $return_headers_sent = false; // ========== HEADERS_SENT - BEGIN // ===== ABOUT // Checks if or where headers have been sent // ===== DESCRIPTION // Checks if or where headers have been sent. // You can't add any more header lines using the header() function once the header block has already been sent. Using this function you can at least prevent getting HTTP header related error messages. Another option is to use Output Buffering. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // headers_sent(string &$filename = null, int &$line = null): bool // ===== CODE $return_headers_sent = headers_sent( $filename, // string& filename - If the optional filename and line parameters are set, headers_sent() will put the PHP source file name and line number where output started in the filename and line variables. // Note: If the output has started before executing the PHP source file (for example due to a startup error), the filename parameter will be set to an empty string. $line // int& line - The line number where the output started. ); // Return Values // headers_sent() will return false if no HTTP headers have already been sent or true otherwise. // // [examples] // Examples // [example] // Example #1 Examples using headers_sent() // [php] // // // If no headers are sent, send one // if (!headers_sent()) { // header('Location: http://www.example.com/'); // exit; // } // // // An example using the optional file and line parameters // // Note that $filename and $linenum are passed in for later use. // // Do not assign them values beforehand. // if (!headers_sent($filename, $linenum)) { // header('Location: http://www.example.com/'); // exit; // // // You would most likely trigger an error here. // } else { // // echo "Headers already sent in $filename on line $linenum\n" . // "Cannot redirect, for now please click this link instead\n"; // exit; // } // // [/php] // [/example] // [/examples] // // Notes // Note: Headers will only be accessible and output when a SAPI that supports them is in use. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.headers-sent.php // ========== HEADERS_SENT - END // SYNTAX: // bool headers_sent(string& $filename, int& $line) return $return_headers_sent; // bool } // ============================== END // PHP_OTHER_NETWORK_HEADERS_SENT // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_HTTP_RESPONSE_CODE // ============================== OFFLINE // ============================== ABOUT // Get or Set the HTTP response code. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // http_response_code() - PHP_5 >= PHP_5_4_0, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_http_response_code($response_code = 0) { $return_http_response_code = false; // ========== HTTP_RESPONSE_CODE - BEGIN // ===== ABOUT // Get or Set the HTTP response code // ===== DESCRIPTION // Gets or sets the HTTP response status code. // ===== SUPPORTED // PHP_5 >= PHP_5_4_0, PHP_7, PHP_8 // ===== SYNTAX // http_response_code(int $response_code = 0): int|bool // ===== CODE $return_http_response_code = http_response_code( $response_code // int response_code - The optional response_code will set the response code. ); // Return Values // If response_code is provided, then the previous status code will be returned. If response_code is not provided, then the current status code will be returned. Both of these values will default to a 200 status code if used in a web server environment. // false will be returned if response_code is not provided and it is not invoked in a web server environment (such as from a CLI application). true will be returned if response_code is provided and it is not invoked in a web server environment (but only when no previous response status has been set). // // [examples] // Examples // [example] // Example #1 Using http_response_code() in a web server environment // [php] // // // Get the current response code and set a new one // var_dump(http_response_code(404)); // // // Get the new response code // var_dump(http_response_code()); // [/php] // The above example will output: // [result] // int(200) // int(404) // [/result] // [/example] // [example] Example #2 Using http_response_code() in a CLI environment // [php] // // // Get the current default response code // var_dump(http_response_code()); // // // Set a response code // var_dump(http_response_code(201)); // // // Get the new response code // var_dump(http_response_code()); // [/php] // The above example will output: // [result] // bool(false) // bool(true) // int(201) // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.http-response-code.php // ========== HTTP_RESPONSE_CODE - END // SYNTAX: // int|bool http_response_code(int $response_code = 0) return $return_http_response_code; // int|bool } */ // ============================== END // PHP_OTHER_NETWORK_HTTP_RESPONSE_CODE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_INET_NTOP // ============================== OFFLINE // ============================== ABOUT // Converts a packed internet address to a human readable representation. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // inet_ntop() - PHP_5 >= PHP_5_1_0, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_inet_ntop($ip) { $return_inet_ntop = false; // ========== INET_NTOP - BEGIN // ===== ABOUT // Converts a packed internet address to a human readable representation // ===== DESCRIPTION // This function converts a 32bit IPv4, or 128bit IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropriate string representation. // ===== SUPPORTED // PHP_5 >= PHP_5_1_0, PHP_7, PHP_8 // ===== SYNTAX // inet_ntop(string $ip): string|false // ===== CODE $return_inet_ntop = inet_ntop( $ip // string ip - A 32bit IPv4, or 128bit IPv6 address. ); // Return Values // Returns a string representation of the address or false on failure. // // [examples] // Examples // [example] // Example #1 inet_ntop() Example // [php] // $packed = chr(127) . chr(0) . chr(0) . chr(1); // $expanded = inet_ntop($packed); // // // Outputs: 127.0.0.1 // echo $expanded; // // $packed = str_repeat(chr(0), 15) . chr(1); // $expanded = inet_ntop($packed); // // // Outputs: ::1 // echo $expanded; // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.inet-ntop.php // ========== INET_NTOP - END // SYNTAX: // string|false inet_ntop(string $ip) return $return_inet_ntop; // string|false } */ // ============================== END // PHP_OTHER_NETWORK_INET_NTOP // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_INET_PTON // ============================== OFFLINE // ============================== ABOUT // Converts a human readable IP address to its packed in_addr representation. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // inet_pton() - PHP_5 >= PHP_5_1_0, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_inet_pton($ip) { $return_inet_pton = false; // ========== INET_PTON - BEGIN // ===== ABOUT // Converts a human readable IP address to its packed in_addr representation // ===== DESCRIPTION // This function converts a human readable IPv4 or IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropriate 32bit or 128bit binary structure. // ===== SUPPORTED // PHP_5 >= PHP_5_1_0, PHP_7, PHP_8 // ===== SYNTAX // inet_pton(string $ip): string|false // ===== CODE $return_inet_pton = inet_pton( $ip // string ip - A human readable IPv4 or IPv6 address. ); // Return Values // Returns the in_addr representation of the given ip, or false if a syntactically invalid ip is given (for example, an IPv4 address without dots or an IPv6 address without colons). // // [examples] // Examples // [example] // Example #1 inet_pton() Example // [php] // $in_addr = inet_pton('127.0.0.1'); // // $in6_addr = inet_pton('::1'); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.inet-pton.php // ========== INET_PTON - END // SYNTAX: // string|false inet_pton(string $ip) return $return_inet_pton; // string|false } */ // ============================== END // PHP_OTHER_NETWORK_INET_PTON // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_IP2LONG // ============================== PUBLIC // ============================== ABOUT // Converts a string containing an (IPv4) Internet Protocol dotted address into a long integer. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ip2long() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_ip2long($ip) { $return_ip2long = false; // ========== IP2LONG - BEGIN // ===== ABOUT // Converts a string containing an (IPv4) Internet Protocol dotted address into a long integer // ===== DESCRIPTION // The function ip2long() generates a long integer representation of IPv4 Internet network address from its Internet standard format (dotted string) representation. // ip2long() will also work with non-complete IP addresses. Read > http://ps-2.kev009.com/wisclibrary/aix52/usr/share/man/info/en_US/a_doc_lib/libs/commtrf2/inet_addr.htm for more info. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ip2long(string $ip): int|false // ===== CODE $return_ip2long = ip2long( $ip // string ip - A standard format address. ); // Return Values // Returns the long integer or false if ip is invalid. // // [examples] // Examples // [example] // Example #1 ip2long() Example // [php] // $ip = gethostbyname('www.example.com'); // $out = "The following URLs are equivalent:
\n"; // $out .= 'http://www.example.com/, http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/
\n"; // echo $out; // [/php] // [/example] // [example] // Example #2 Displaying an IP address // This second example shows how to print a converted address with the printf() function: // [php] // $ip = gethostbyname('www.example.com'); // $long = ip2long($ip); // // if ($long == -1 || $long === FALSE) { // echo 'Invalid IP, please try again'; // } else { // echo $ip . "\n"; // 192.0.34.166 // echo $long . "\n"; // 3221234342 (-1073732954 on 32-bit systems, due to integer overflow) // printf("%u\n", ip2long($ip)); // 3221234342 // } // [/php] // [/example] // [/examples] // // Notes // Note: Because PHP's int type is signed, and many IP addresses will result in negative integers on 32-bit architectures, you need to use the "%u" formatter of sprintf() or printf() to get the string representation of the unsigned IP address. // Note: ip2long() will return -1 for the IP 255.255.255.255 on 32-bit systems due to the integer value overflowing. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.ip2long.php // ========== IP2LONG - END // SYNTAX: // int|false ip2long(string $ip) return $return_ip2long; // int|false } // ============================== END // PHP_OTHER_NETWORK_IP2LONG // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_LONG2IP // ============================== PUBLIC // ============================== ABOUT // Converts a long integer address into a string in (IPv4) Internet standard dotted format. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // long2ip() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_long2ip($ip) { $return_long2ip = false; // ========== LONG2IP - BEGIN // ===== ABOUT // Converts a long integer address into a string in (IPv4) Internet standard dotted format // ===== DESCRIPTION // The function long2ip() generates an Internet address in dotted format (i.e.: aaa.bbb.ccc.ddd) from the long integer representation. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // long2ip(int $ip): string|false // ===== CODE $return_long2ip = long2ip( $ip // int ip - A proper address representation in long integer. ); // Return Values // Returns the Internet IP address as a string, or false on failure. // // Changelog // Version - Description // 7.1.0 - The parameter type of ip has been changed from string to int. // // Notes // Note: On 32-bit architectures, casting integer representations of IP addresses from string to int will not give correct results for numbers which exceed PHP_INT_MAX. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.long2ip.php // ========== LONG2IP - END // SYNTAX: // string|false long2ip(int $ip) return $return_long2ip; // string|false } // ============================== END // PHP_OTHER_NETWORK_LONG2IP // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_NET_GET_INTERFACES // ============================== OFFLINE // ============================== ABOUT // Get network interfaces. // ============================== SUPPORT // PHP_7 - PHP_8 // ============================== USING FUNCTIONS (1) // net_get_interfaces() - PHP_7 >= PHP_7_3, PHP_8 // ============================== CODE /* function php_other_network_net_get_interfaces() { $return_net_get_interfaces = false; // ========== NET_GET_INTERFACES - BEGIN // ===== ABOUT // Get network interfaces // ===== DESCRIPTION // Returns an enumeration of network interfaces (adapters) on the local machine. // ===== SUPPORTED // PHP_7 >= PHP_7_3, PHP_8 // ===== SYNTAX // net_get_interfaces(): array|false // ===== CODE $return_net_get_interfaces = net_get_interfaces( // This function has no parameters. ); // Return Values // Returns an associative array where the key is the name of the interface and the value an associative array of interface attributes, or false on failure. // Each interface associative array contains: // Interface attributes // Name - Description // description - Optional string value for description of the interface. Windows only. // mac - Optional string value for MAC address of the interface. Windows only. // mtu - Integer value for Maximum transmission unit (MTU) of the interface. Windows only. // unicast - Array of associative arrays, see Unicast attributes below. // up - Boolean status (on/off) for interface. // Unicast attributes // Name - Description // flags - Integer value. // family - Integer value. // address - String value for address in either IPv4 or IPv6. // netmask - String value for netmask in either IPv4 or IPv6. // // Errors/Exceptions // Emits an E_WARNING on failure to get interface information. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.net-get-interfaces.php // ========== NET_GET_INTERFACES - END // SYNTAX: // array|false net_get_interfaces() return $return_net_get_interfaces; // array|false } */ // ============================== END // PHP_OTHER_NETWORK_NET_GET_INTERFACES // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_OPENLOG // ============================== PUBLIC // ============================== ABOUT // Open connection to system logger. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // openlog() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_openlog($prefix, $flags, $facility) { $return_openlog = false; // ========== OPENLOG - BEGIN // ===== ABOUT // Open connection to system logger // ===== DESCRIPTION // openlog() opens a connection to the system logger for a program. // The use of openlog() is optional. It will automatically be called by syslog() if necessary, in which case prefix will default to false. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // openlog(string $prefix, int $flags, int $facility): bool // ===== CODE $return_openlog = openlog( $prefix, // string prefix - The string prefix is added to each message. $flags, // int flags - The flags argument is used to indicate what logging options will be used when generating a log message. // openlog() Options // Constant - Description // LOG_CONS - if there is an error while sending data to the system logger, write directly to the system console // LOG_NDELAY - open the connection to the logger immediately // LOG_ODELAY - (default) delay opening the connection until the first message is logged // LOG_PERROR - print log message also to standard error // LOG_PID - include PID with each message // You can use one or more of these options. When using multiple options you need to OR them, i.e. to open the connection immediately, write to the console and include the PID in each message, you will use: LOG_CONS | LOG_NDELAY | LOG_PID $facility // int facility - The facility argument is used to specify what type of program is logging the message. This allows you to specify (in your machine's syslog configuration) how messages coming from different facilities will be handled. // openlog() Facilities // Constant - Description // LOG_AUTH - security/authorization messages (use LOG_AUTHPRIV instead in systems where that constant is defined) // LOG_AUTHPRIV - security/authorization messages (private) // LOG_CRON - clock daemon (cron and at) // LOG_DAEMON - other system daemons // LOG_KERN - kernel messages // LOG_LOCAL0 ... LOG_LOCAL7 - reserved for local use, these are not available in Windows // LOG_LPR - line printer subsystem // LOG_MAIL - mail subsystem // LOG_NEWS - USENET news subsystem // LOG_SYSLOG - messages generated internally by syslogd // LOG_USER - generic user-level messages // LOG_UUCP - UUCP subsystem // Note: LOG_USER is the only valid log type under Windows operating systems ); // Return Values // Returns true on success or false on failure. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.openlog.php // ========== OPENLOG - END // SYNTAX: // bool openlog(string $prefix, int $flags, int $facility) return $return_openlog; // bool } // ============================== END // PHP_OTHER_NETWORK_OPENLOG // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_PFSOCKOPEN // ============================== PUBLIC // ============================== ABOUT // Open persistent Internet or Unix domain socket connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // pfsockopen() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_pfsockopen($hostname, $port = -1, & $error_code, & $error_message, $timeout) { $return_pfsockopen = false; // ========== PFSOCKOPEN - BEGIN // ===== ABOUT // Open persistent Internet or Unix domain socket connection // ===== DESCRIPTION // This function behaves exactly as fsockopen() with the difference that the connection is not closed after the script finishes. It is the persistent version of fsockopen(). // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // pfsockopen( // string $hostname, // int $port = -1, // int &$error_code = null, // string &$error_message = null, // ?float $timeout = null // ): resource|false // ===== CODE $return_pfsockopen = pfsockopen( // For parameter information, see the fsockopen() documentation. $hostname, // string $hostname $port, // int $port $error_code, // int& $error_code $error_message, // string& $error_message $timeout // float $timeout ); // Return Values // pfsockopen() returns a file pointer which may be used together with the other file functions (such as fgets(), fgetss(), fwrite(), fclose(), and feof()), or false on failure. // // Changelog // Version - Description // 8.0.0 - timeout is nullable now. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.pfsockopen.php // ========== PFSOCKOPEN - END // SYNTAX: // resource|false pfsockopen(string $hostname, int $port = -1, int& $error_code, string& $error_message, float $timeout) return $return_pfsockopen; // resource|false } // ============================== END // PHP_OTHER_NETWORK_PFSOCKOPEN // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SETCOOKIE // ============================== PUBLIC // ============================== ABOUT // Send a cookie. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // setcookie() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_setcookie($name, $value = "", $expires_or_options = 0, $path = "", $domain = "", $secure = false, $httponly = false) { $return_setcookie = false; // ========== SETCOOKIE - BEGIN // ===== ABOUT // Send a cookie // ===== DESCRIPTION // setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including and tags as well as any whitespace. // Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE array. Cookie values may also exist in $_REQUEST. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // setcookie( // string $name, // string $value = "", // int $expires_or_options = 0, // string $path = "", // string $domain = "", // bool $secure = false, // bool $httponly = false // ): bool // // Alternative signature available as of PHP 7.3.0 (not supported with named parameters): // setcookie(string $name, string $value = "", array $options = []): bool // ===== CODE $return_setcookie = setcookie( // > RFC 6265 provides the normative reference on how each setcookie() parameter is interpreted. $name, // string name - The name of the cookie. $value, // string value - The value of the cookie. This value is stored on the clients computer; do not store sensitive information. Assuming the name is 'cookiename', this value is retrieved through $_COOKIE['cookiename'] $expires_or_options, // int expires_or_options - The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. One way to set this is by adding the number of seconds before the cookie should expire to the result of calling time(). For instance, time()+60*60*24*30 will set the cookie to expire in 30 days. Another option is to use the mktime() function. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes). // Note: You may notice the expires_or_options parameter takes on a Unix timestamp, as opposed to the date format Wdy, DD-Mon-YYYY HH:MM:SS GMT, this is because PHP does this conversion internally. $path, // string path - The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in. $domain, // string domain - The (sub)domain that the cookie is available to. Setting this to a subdomain (such as 'www.example.com') will make the cookie available to that subdomain and all other sub-domains of it (i.e. w2.www.example.com). To make the cookie available to the whole domain (including all subdomains of it), simply set the value to the domain name ('example.com', in this case). // Older browsers still implementing the deprecated > RFC 2109 may require a leading . to match all subdomains. $secure, // bool secure - Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client. When set to true, the cookie will only be set if a secure connection exists. On the server-side, it's on the programmer to send this kind of cookie only on secure connection (e.g. with respect to $_SERVER["HTTPS"]). $httponly // bool httponly - When true the cookie will be made accessible only through the HTTP protocol. This means that the cookie won't be accessible by scripting languages, such as JavaScript. It has been suggested that this setting can effectively help to reduce identity theft through XSS attacks (although it is not supported by all browsers), but that claim is often disputed. true or false // array options - An associative array which may have any of the keys expires, path, domain, secure, httponly and samesite. If any other key is present an error of level E_WARNING is generated. The values have the same meaning as described for the parameters with the same name. The value of the samesite element should be either None, Lax or Strict. If any of the allowed options are not given, their default values are the same as the default values of the explicit parameters. If the samesite element is omitted, no SameSite cookie attribute is set. ); // Return Values // If output exists prior to calling this function, setcookie() will fail and return false. If setcookie() successfully runs, it will return true. This does not indicate whether the user accepted the cookie. // // Changelog // Version - Description // 8.2.0 - The date format of the cookie is now 'D, d M Y H:i:s \G\M\T'; previously it was 'D, d-M-Y H:i:s T'. // 7.3.0 - An alternative signature supporting an options array has been added. This signature supports also setting of the SameSite cookie attribute. // // [examples] // Examples // Some examples follow how to send cookies: // [example] // Example #1 setcookie() send example // [php] // $value = 'something from somewhere'; // // setcookie("TestCookie", $value); // setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */ // setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1); // [/php] // Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. If you don't want this, you can use setrawcookie() instead. To see the contents of our test cookie in a script, simply use one of the following examples: // [php] // // Print an individual cookie // echo $_COOKIE["TestCookie"]; // // // Another way to debug/test is to view all cookies // print_r($_COOKIE); // [/php] // [/example] // [example] // Example #2 setcookie() delete example // When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser. Examples follow how to delete cookies sent in previous example: // [php] // // set the expiration date to one hour ago // setcookie("TestCookie", "", time() - 3600); // setcookie("TestCookie", "", time() - 3600, "/~rasmus/", "example.com", 1); // [/php] // [/example] // [example] // Example #3 setcookie() and arrays // You may also set array cookies by using array notation in the cookie name. This has the effect of setting as many cookies as you have array elements, but when the cookie is received by your script, the values are all placed in an array with the cookie's name: // [php] // // set the cookies // setcookie("cookie[three]", "cookiethree"); // setcookie("cookie[two]", "cookietwo"); // setcookie("cookie[one]", "cookieone"); // // // after the page reloads, print them out // if (isset($_COOKIE['cookie'])) { // foreach ($_COOKIE['cookie'] as $name => $value) { // $name = htmlspecialchars($name); // $value = htmlspecialchars($value); // echo "$name : $value
\n"; // } // } // [/php] // The above example will output: // [result] // three : cookiethree // two : cookietwo // one : cookieone // [/result] // Note: Using separator characters such as [ and ] as part of the cookie name is not compliant to RFC 6265, section 4, but supposed to be supported by user agents according to RFC 6265, section 5. // [/example] // [/examples] // // Notes // Note: You can use output buffering to send output prior to the call of this function, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files. // Common Pitfalls: // * Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expires_or_options parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);. // * Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. This is internally achieved by setting value to 'deleted' and expiration time in the past. // * Because setting a cookie with a value of false will try to delete the cookie, you should not use boolean values. Instead, use 0 for false and 1 for true. // * Cookies names can be set as array names and will be available to your PHP scripts as arrays but separate cookies are stored on the user's system. Consider explode() to set one cookie with multiple names and values. It is not recommended to use serialize() for this purpose, because it can result in security holes. // Multiple calls to setcookie() are performed in the order called. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.setcookie.php // ========== SETCOOKIE - END // SYNTAX: // bool setcookie(string $name, string $value = "", int $expires_or_options = 0, string $path = "", string $domain = "", bool $secure = false, bool $httponly = false) return $return_setcookie; // bool } // ============================== END // PHP_OTHER_NETWORK_SETCOOKIE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SETRAWCOOKIE // ============================== OFFLINE // ============================== ABOUT // Send a cookie without urlencoding the cookie value. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // setrawcookie() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_network_setrawcookie($name, $value, $expires_or_options, $path, $domain, $secure = false, $httponly = false) { $return_setrawcookie = false; // ========== SETRAWCOOKIE - BEGIN // ===== ABOUT // Send a cookie without urlencoding the cookie value // ===== DESCRIPTION // setrawcookie() is exactly the same as setcookie() except that the cookie value will not be automatically urlencoded when sent to the browser. // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // setrawcookie( // string $name, // string $value = ?, // int $expires_or_options = 0, // string $path = ?, // string $domain = ?, // bool $secure = false, // bool $httponly = false // ): bool // // Alternative signature available as of PHP 7.3.0 (not supported with named parameters): // setrawcookie(string $name, string $value = ?, array $options = []): bool // ===== CODE $return_setrawcookie = setrawcookie( // For parameter information, see the setcookie() documentation. $name, // string $name $value, // string $value $expires_or_options, // int $expires_or_options $path, // string $path $domain, // string $domain $secure, // bool $secure $httponly // bool $httponly ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 7.3.0 - An alternative signature supporting an options array has been added. This signature supports also setting of the SameSite cookie attribute. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-13) // URL: https://www.php.net/manual/en/function.setrawcookie.php // ========== SETRAWCOOKIE - END // SYNTAX: // bool setrawcookie(string $name, string $value, int $expires_or_options, string $path, string $domain, bool $secure = false, bool $httponly = false) return $return_setrawcookie; // bool } */ // ============================== END // PHP_OTHER_NETWORK_SETRAWCOOKIE // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SOCKET_GET_STATUS // ============================== PUBLIC // ============================== ABOUT // Retrieves header/meta data from streams/file pointers. // // socket_get_status - Alias of stream_get_meta_data(). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // socket_get_status() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_socket_get_status($stream) { $return_socket_get_status = null; // ========== SOCKET_GET_STATUS - BEGIN // ===== ABOUT // socket_get_status - Alias of stream_get_meta_data() // ===== DESCRIPTION // This function is an alias of: stream_get_meta_data(). // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_socket_get_status = socket_get_status( $stream // resource $stream ); // Return // array // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.socket-get-status.php // ========== SOCKET_GET_STATUS - END // ========== STREAM_GET_META_DATA - BEGIN // ===== ABOUT // Retrieves header/meta data from streams/file pointers // ===== DESCRIPTION // Returns information about an existing stream. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // stream_get_meta_data(resource $stream): array // ===== CODE // $return_stream_get_meta_data = stream_get_meta_data( // $stream // resource stream - The stream can be any stream created by fopen(), fsockopen() pfsockopen() and stream_socket_client(). // ); // Return Values // The result array contains the following items: // * timed_out (bool) - true if the stream timed out while waiting for data on the last call to fread() or fgets(). // * blocked (bool) - true if the stream is in blocking IO mode. See stream_set_blocking(). // * eof (bool) - true if the stream has reached end-of-file. Note that for socket streams this member can be true even when unread_bytes is non-zero. To determine if there is more data to be read, use feof() instead of reading this item. // * unread_bytes (int) - the number of bytes currently contained in the PHP's own internal buffer. // Note: You shouldn't use this value in a script. // * stream_type (string) - a label describing the underlying implementation of the stream. // * wrapper_type (string) - a label describing the protocol wrapper implementation layered over the stream. See Supported Protocols and Wrappers for more information about wrappers. // * wrapper_data (mixed) - wrapper specific data attached to this stream. See Supported Protocols and Wrappers for more information about wrappers and their wrapper data. // * mode (string) - the type of access required for this stream (see Table 1 of the fopen() reference) // * seekable (bool) - whether the current stream can be seeked. // * uri (string) - the URI/filename associated with this stream. // * crypto (array) - the TLS connection metadata for this stream. (Note: Only provided when the resource's stream uses TLS.) // // [examples] // Examples // [example] // Example #1 stream_get_meta_data() example using fopen() with http // [php] // $url = 'http://www.example.com/'; // // if (!$fp = fopen($url, 'r')) { // trigger_error("Unable to open URL ($url)", E_USER_ERROR); // } // // $meta = stream_get_meta_data($fp); // // var_dump($meta); // // fclose($fp); // [/php] // The above example will output something similar to: // [result] // array(10) { // 'timed_out' => // bool(false) // 'blocked' => // bool(true) // 'eof' => // bool(false) // 'wrapper_data' => // array(13) { // [0] => // string(15) "HTTP/1.1 200 OK" // [1] => // string(11) "Age: 244629" // [2] => // string(29) "Cache-Control: max-age=604800" // [3] => // string(38) "Content-Type: text/html; charset=UTF-8" // [4] => // string(35) "Date: Sat, 20 Nov 2021 18:17:57 GMT" // [5] => // string(24) "Etag: "3147526947+ident"" // [6] => // string(38) "Expires: Sat, 27 Nov 2021 18:17:57 GMT" // [7] => // string(44) "Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT" // [8] => // string(22) "Server: ECS (chb/0286)" // [9] => // string(21) "Vary: Accept-Encoding" // [10] => // string(12) "X-Cache: HIT" // [11] => // string(20) "Content-Length: 1256" // [12] => // string(17) "Connection: close" // } // 'wrapper_type' => // string(4) "http" // 'stream_type' => // string(14) "tcp_socket/ssl" // 'mode' => // string(1) "r" // 'unread_bytes' => // int(1256) // 'seekable' => // bool(false) // 'uri' => // string(23) "http://www.example.com/" // } // [/result] // [/example] // [example] // Example #2 stream_get_meta_data() example using stream_socket_client() with https // [php] // $streamContext = stream_context_create( // [ // 'ssl' => [ // 'capture_peer_cert' => true, // 'capture_peer_cert_chain' => true, // 'disable_compression' => true, // ], // ] // ); // // $client = stream_socket_client( // 'ssl://www.example.com:443', // $errorNumber, // $errorDescription, // 40, // STREAM_CLIENT_CONNECT, // $streamContext // ); // // // $meta = stream_get_meta_data($client); // // var_dump($meta); // [/php] // The above example will output something similar to: // [result] // array(8) { // 'crypto' => // array(4) { // 'protocol' => // string(7) "TLSv1.3" // 'cipher_name' => // string(22) "TLS_AES_256_GCM_SHA384" // 'cipher_bits' => // int(256) // 'cipher_version' => // string(7) "TLSv1.3" // } // 'timed_out' => // bool(false) // 'blocked' => // bool(true) // 'eof' => // bool(false) // 'stream_type' => // string(14) "tcp_socket/ssl" // 'mode' => // string(2) "r+" // 'unread_bytes' => // int(0) // 'seekable' => // bool(false) // } // [/result] // [/example] // [/examples] // // Notes // Note: This function does NOT work on sockets created by the Socket extension. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.stream-get-meta-data.php // ========== STREAM_GET_META_DATA - END // SYNTAX: // array socket_get_status(resource $stream) return $return_socket_get_status; // array } // ============================== END // PHP_OTHER_NETWORK_SOCKET_GET_STATUS // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SOCKET_SET_BLOCKING // ============================== PUBLIC // ============================== ABOUT // Set blocking/non-blocking mode on a stream. // // socket_set_blocking - Alias of stream_set_blocking(). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // socket_set_blocking() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_socket_set_blocking($stream, $enable) { $return_socket_set_blocking = false; // ========== SOCKET_SET_BLOCKING - BEGIN // ===== ABOUT // socket_set_blocking - Alias of stream_set_blocking() // ===== DESCRIPTION // This function is an alias of: stream_set_blocking(). // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_socket_set_blocking = socket_set_blocking( $stream, // resource stream $enable // bool enable ); // Return // bool // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.socket-set-blocking.php // ========== SOCKET_SET_BLOCKING - END // ========== STREAM_SET_BLOCKING - BEGIN // ===== ABOUT // Set blocking/non-blocking mode on a stream // ===== DESCRIPTION // Sets blocking or non-blocking mode on a stream. // This function works for any stream that supports non-blocking mode (currently, regular files and socket streams). // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // stream_set_blocking(resource $stream, bool $enable): bool // ===== CODE // $return_stream_set_blocking = stream_set_blocking( // $stream, // resource stream - The stream. // $enable // bool enable - If enable is false, the given stream will be switched to non-blocking mode, and if true, it will be switched to blocking mode. This affects calls like fgets() and fread() that read from the stream. In non-blocking mode an fgets() call will always return right away while in blocking mode it will wait for data to become available on the stream. // ); // Return Values // Returns true on success or false on failure. // // Notes // Note: On Windows, this has no affect on local files. Non-blocking IO for local files is not supported on Windows. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-30) // URL: https://www.php.net/manual/en/function.stream-set-blocking.php // ========== STREAM_SET_BLOCKING - END // SYNTAX: // bool socket_set_blocking(resource $stream, bool $enable) return $return_socket_set_blocking; // bool } // ============================== END // PHP_OTHER_NETWORK_SOCKET_SET_BLOCKING // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SOCKET_SET_TIMEOUT // ============================== PUBLIC // ============================== ABOUT // Set timeout period on a stream. // // socket_set_timeout - Alias of stream_set_timeout(). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // socket_set_timeout() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_socket_set_timeout($stream, $seconds, $microseconds = 0) { $return_socket_set_timeout = false; // ========== SOCKET_SET_TIMEOUT - BEGIN // ===== ABOUT // socket_set_timeout - Alias of stream_set_timeout() // ===== DESCRIPTION // This function is an alias of: stream_set_timeout(). // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_socket_set_timeout = socket_set_timeout( $stream, // resource stream $seconds, // int seconds $microseconds // int microseconds ); // Return // bool // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.socket-set-timeout.php // ========== SOCKET_SET_TIMEOUT - END // ========== STREAM_SET_TIMEOUT - BEGIN // ===== ABOUT // Set timeout period on a stream // ===== DESCRIPTION // Sets the timeout value on stream, expressed in the sum of seconds and microseconds. // When the stream times out, the 'timed_out' key of the array returned by stream_get_meta_data() is set to true, although no error/warning is generated. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // stream_set_timeout(resource $stream, int $seconds, int $microseconds = 0): bool // ===== CODE // $return_stream_set_timeout = stream_set_timeout( // $stream, // resource stream - The target stream. // $seconds, // int seconds - The seconds part of the timeout to be set. // $microseconds // int microseconds - The microseconds part of the timeout to be set. // ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 stream_set_timeout() example // [php] // $fp = fsockopen("www.example.com", 80); // if (!$fp) { // echo "Unable to open\n"; // } else { // // fwrite($fp, "GET / HTTP/1.0\r\n\r\n"); // stream_set_timeout($fp, 2); // $res = fread($fp, 2000); // // $info = stream_get_meta_data($fp); // fclose($fp); // // if ($info['timed_out']) { // echo 'Connection timed out!'; // } else { // echo $res; // } // // } // [/php] // [/example] // [/examples] // // Notes // Note: This function doesn't work with advanced operations like stream_socket_recvfrom(), use stream_select() with timeout parameter instead. // This function was previously called as set_socket_timeout() and later socket_set_timeout() but this usage is deprecated. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.stream-set-timeout.php // ========== STREAM_SET_TIMEOUT - END // SYNTAX: // bool socket_set_timeout(resource $stream, int $seconds, int $microseconds = 0) return $return_socket_set_timeout; // bool } // ============================== END // PHP_OTHER_NETWORK_SOCKET_SET_TIMEOUT // ============================== // ============================== BEGIN // PHP_OTHER_NETWORK_SYSLOG // ============================== PUBLIC // ============================== ABOUT // Generate a system log message. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // syslog() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_network_syslog($priority, $message) { $return_syslog = false; // ========== SYSLOG - BEGIN // ===== ABOUT // Generate a system log message // ===== DESCRIPTION // syslog() generates a log message that will be distributed by the system logger. // For information on setting up a user defined log handler, see the syslog.conf (5) Unix manual page. More information on the syslog facilities and option can be found in the man pages for syslog (3) on Unix machines. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // syslog(int $priority, string $message): true // ===== CODE $return_syslog = syslog( $priority, // int priority - priority is a combination of the facility and the level. Possible values are: // syslog() Priorities (in descending order) // Constant - Description // LOG_EMERG - system is unusable // LOG_ALERT - action must be taken immediately // LOG_CRIT - critical conditions // LOG_ERR - error conditions // LOG_WARNING - warning conditions // LOG_NOTICE - normal, but significant, condition // LOG_INFO - informational message // LOG_DEBUG - debug-level message $message // string message - The message to send. ); // Return Values // Always returns true. // // [examples] // Examples // [example] // Example #1 Using syslog() // [php] // // open syslog, include the process ID and also send // // the log to standard error, and use a user defined // // logging mechanism // openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); // // // some code // // if (authorized_client()) { // // do something // } else { // // unauthorized client! // // log the attempt // $access = date("Y/m/d H:i:s"); // syslog(LOG_WARNING, "Unauthorized client: $access {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})"); // } // // closelog(); // [/php] // [/example] // [/examples] // // Notes // On Windows, the syslog service is emulated using the Event Log. // Note: Use of LOG_LOCAL0 through LOG_LOCAL7 for the facility parameter of openlog() is not available in Windows. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-12) // URL: https://www.php.net/manual/en/function.syslog.php // ========== SYSLOG - END // SYNTAX: // bool syslog(int $priority, string $message) return $return_syslog; // bool } // ============================== END // PHP_OTHER_NETWORK_SYSLOG // ============================== // ============================== END // PHP_OTHER_NETWORK // ============================== ?>