cURL extension
- Enable extension in
php.ini
file:
extension=curl
- Send POST request:
<?php
$data = 'name=John&age=20';
$ch = curl_init('https://httpbin.org/post');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$content = curl_exec($ch);
curl_close($ch);
echo $content;
Leave a Comment
Cancel reply