How to convert this wget function to php?

view story

http://stackoverflow.com – wget -d --header="Content-Type:application/xml" --post-data="$(cat <your xml file>)" http://sample.sample.com/api How do i use this function in php? I want also to get the response from this function. i have a variable in php the viable is like this $xml = '<sample> <Request target="test"> </Request> </sample>' This is the xml that i want to post. I tried the following: $url = 'sample.sample.com/api';; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "$(cat <".$xml."&gt (HowTos)