I have this:
$animal=cat;
how can I add single quotes to this variable to get an output of, for example, 'cat'?
echo "$animal";
//Output 'cat'
I have this:
$animal=cat;
how can I add single quotes to this variable to get an output of, for example, 'cat'?
echo "$animal";
//Output 'cat'
echo "'$animal'";
Just write signle quotes before and after variable but remember variable should be written in double quotes
You can do
echo "\"$animal\"";
Or you can just use single quotes instead as the following:
echo '"$animal"';
Whichever you prefer.