PHP | dns_get_mx() Function Last Updated : 03 Sep, 2019 Comments Improve Suggest changes Like Article Like Report The dns_get_mx() function is an inbuilt function in PHP which returns MX records for the specified internet host name. This function is an alias of the getmxrr() function. Syntax: bool dns_get_mx( $host, $mxhosts, $weight ); Parameter: This function accepts three parameters as mentioned above and described below: $host: It is required parameter. It specifies the host name whose MX records to be found. $mxhosts: It is required parameter. An array specifies MX host names found. $weight: It is optional parameter. An array filled with weight information gathered. Return Value: This function returns TRUE if any record(s) found, otherwise returns FALSE. Note: This function is available for PHP 5.0.0 and newer version. Below programs illustrate the dns_get_mx() function in PHP: Program 1: php <?php $domain = "geeksforgeeks.org"; if(dns_get_mx($domain, $mx_details)) { foreach( $mx_details as $key => $value) { echo "$key => $value <br>"; } } ?> Output: 0 => alt3.aspmx.l.google.com 1 => alt4.aspmx.l.google.com 2 => aspmx.l.google.com 3 => alt2.aspmx.l.google.com 4 => alt1.aspmx.l.google.com Program 2: php <?php $domain = "yahoo.com"; if(dns_get_mx($domain, $mx_details)) { foreach( $mx_details as $key => $value ) { echo "$key => $value <br>"; } } ?> Output: 0 => mta5.am0.yahoodns.net 1 => mta6.am0.yahoodns.net 2 => mta7.am0.yahoodns.net Reference: https://www.php.net/manual/en/function.dns-get-mx.php Comment More infoAdvertise with us Next Article PHP | dns_get_mx() Function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP Memcached get() Function The Memcached::get() function is an inbuilt function of memcached class in PHP which is used to get the value under a given key stored on memcache server. Syntax: public Memcached::get( $key, callable $cache_cb = ?, $$flags = ?): mixed Parameters: This function accepts three parameters that are: key 3 min read PHP | get_defined_vars() Function The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc. Syntax: array get_defined_vars( void ) Parameters: This function does no 1 min read PHP | gethostname() Function The gethostname() function is an inbuilt function in PHP which returns the host or domain name for the local machine. This function is applicable after PHP 5.3.0 before that there was another function called php_uname function. Syntax: string gethostname( void ) Parameters: This function doesn't acc 1 min read PHP | gethostnamel() Function The gethostbynamel() function is an inbuilt function in PHP which returns a list of IPv4 address for a specified internet host/domain name. Syntax: gethostbynamel( string $hostname ) Parameters: This function accepts single parameter $hostname which is required. It specifies the hostname whose IPv4 1 min read PHP | inet_ntop() Function The inet_ntop() function is an inbuilt function in PHP which converts a 32bit IPv4 or 128bit IPv6 address into a readable format. Syntax: string inet_ntop( string $ip_address ) Parameter: This function accepts one parameter as mentioned above and described below: $ip_address: It is required paramete 1 min read PHP | DateTimeZone::getName() Function The DateTimeZone::getName() function is an inbuilt function in PHP which is used to return the name of the created timezone. Syntax: DateTimeZone::getName() Parameters: This function does not accept any parameter. Return Values:: This function return the name of the created timezone. Below programs 1 min read PHP | stream_get_meta_data() Function The stream_get_meta_data() function is an inbuilt function in PHP which is used to get the header or meta data from the streams/file pointers.Syntax: array stream_get_meta_data( $stream ) Parameters: The function accepts single parameter $stream, which specifies the meta data to be retrieve and whic 2 min read PHP | checkdnsrr() Function The checkdnsrr() function is an inbuilt function in PHP that is used to check the DNS records corresponding to the hostname or IP address. This function can be used to verify whether a domain name exists or not. Syntax:Â bool checkdnsrr( string $host, string $type ) Parameters: This function accepts 2 min read PHP | gethostbyname() Function The gethostbyname() function is an inbuilt function in PHP which returns IPv4 address for a specified host/domain name. Syntax: string gethostbyname( $hostname ) Parameter: This function accepts single parameter $hostname which is required. It specifies the hostname whose IPv4 address to be found. R 1 min read PHP | geoip_asnum_by_name() Function The geoip_asnum_by_name() is an inbuilt function in PHP which helps us to get the Autonomous System Number (ASN). The function will help us to get the ASN by taking an IP address as an argument . Syntax : string geoip_asnum_by_name ( string $hostname ) Parameters : The function accepts a single para 1 min read Like