Hey everyone,
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:
```php
$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!

Hey there,
I totally understand your struggle with using a PHP variable in the `dns_get_record` function. I've faced a similar issue in the past, and luckily, I found a solution that worked for me.
In my case, I had to retrieve DNS records dynamically based on user input, just like you. What I did was use the `dns_get_record` function along with the `gethostbyname` function to achieve the desired result.
Here's an example of how you can implement it:
By using the `gethostbyname` function, I was able to convert the domain name provided by the user into its corresponding IP address. Then, I used that IP address as the argument for `dns_get_record` instead of directly using the domain name variable.
This approach allowed me to dynamically fetch DNS records for different domains using user input without any issues.
Give it a try, and let me know if it works for you too. If you have any further questions, feel free to ask!