I've been working on a PHP script that involves using the `dns_get_record` function to fetch DNS records for a specific domain. However, I'm running into a small roadblock.
I need to pass a variable as the domain name argument in the `dns_get_record` function. In other words, I want to be able to dynamically fetch DNS records for different domains based on user input.
Here's an example of what I'm trying to do:
$domain = 'example.com'; // This works fine
$records = dns_get_record($domain, DNS_ANY); // This works fine too
// However, I want to use a variable instead of hardcoding the domain name
$userInput = $_POST['domain']; // Assuming user enters 'example.com' in a form field
$records = dns_get_record($userInput, DNS_ANY); // This doesn't work
The issue is that `dns_get_record` doesn't seem to allow the use of variables as the domain argument. It only accepts a string literal.
I've already made sure that the user input is properly sanitized and validated before using it. So that's not the problem here.
Is there any way to achieve this functionality? I'd greatly appreciate any guidance or suggestions you can provide.
Thanks in advance!