I want to pass the php variable value in onClick function. When i pass the php variable, in the UI i am getting the variable itself instead I need the value in the variable.
I think you are searching for PHP function json_encode which converts PHP variable into JavaScript object.
json_encode
It's more secure than passing the value right in the output.