After reading on web, I learned that XAMPP has php-cli pre-installed and it is accessed by /opt/lampp/bin/php . I installed composer using the following and all went well:
cd /opt/lampp/bin
sudo curl -s https://getcomposer.org/installer | /opt/lampp/bin/php
Composer was installed perfectly. After that, I did this to make it global:
sudo mv composer.phar /usr/local/bin/composer
done!!!
check composer version
composer -V
https://askubuntu.com/questions/604522/install-composer-and-configure-with-xampp