You should redirect stderr to stdout.
To do that, change your exec() call like this:
exec("ping -c 1 $domain_bad 2>&1", $output, $return_var);
More info about 2>&1
meaning here.
More Related Contents:
- PHP exec() vs system() vs passthru()
- php exec command (or similar) to not wait for result
- PHP shell_exec() vs exec()
- Running a Python script from PHP
- How do you run a .bat file from PHP?
- PHP StdErr after Exec()
- Ping site and return result in PHP
- Run Bash Command from PHP
- Running command-line application from PHP as specific user
- Pinging an IP address using PHP and echoing the result
- How can I ping a server port with PHP?
- PHP exec() as Background Process (Windows Wampserver Environment)
- curl and ping – how to check whether a website is either up or down?
- Checking if process still running?
- PHP exec – check if enabled or disabled
- Run a ffmpeg process in the background
- Check if “exec” is disabled [duplicate]
- PHP exec() will not execute shell command when executed via browser
- PHP exec $PATH variable missing elements
- Running python script in Laravel
- Windows CMD.exe “The system cannot find the path specified.”
- Can’t execute PHP script using PHP exec
- exec() with timeout
- PHP exec() not returning error message in output
- What’s the difference between escapeshellarg and escapeshellcmd?
- php in background exec() function
- Find out which class called a method in another class
- What is null coalescing assignment ??= operator in PHP 7.4
- adding 30 minutes to datetime php/mysql
- Detect how long it takes for a file to upload (PHP)