Using curl in bash script

Hello.

I have pick up a script from internet to track errors from curl command.

#!/bin/bash
#
URL_TO_TEST="http://www.xxxxxx.yyy"

MY_VAR=curl_init("$URL_TO_TEST") ;
curl_setopt($MY_VAR, CURLOPT_HEADER, 1);
curl_setopt($MY_VAR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($MY_VAR, CURLOPT_HTTPGET, 1);
curl_setopt($MY_VAR, CURLOPT_URL, "$URL_TO_TEST" );
curl_setopt($MY_VAR, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
curl_setopt($MY_VAR, CURLOPT_DNS_CACHE_TIMEOUT, 2 );

var_dump(curl_exec($MY_VAR));
var_dump(curl_getinfo($MY_VAR));
var_dump(curl_error($MY_VAR)); 

It does not work because I think that the syntax is for php.
Googleing does not help me.

Any help is welcome.

curl return error codes. Here is a manual page that includes most of the error codes.

So you can run a curl command and look at the exit code to get the status:-

$ curl https://domain.com 2> /dev/null

$ print $?
7

Thank you very much for your help.

Thank you very much for your help.