Skip to content

Instantly share code, notes, and snippets.

@vanpariyar
Last active January 7, 2020 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanpariyar/faa85d048c171f65c529fd58720691fd to your computer and use it in GitHub Desktop.
Save vanpariyar/faa85d048c171f65c529fd58720691fd to your computer and use it in GitHub Desktop.
In this gist i have putted the snippets that any one can use in their project development requirement in PHP development if have time i am creating this type of the snippets. You will thanks later.
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$ch = curl_init('http://api.local/rest/users');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment