如何将PHP类转换为json数据?

hello guys i want make json data and post to my URL this is my new code but not work because i don't know how to fix it I actually want to turn this whole information into json and send it to my requested link. Thank you for your help

    class Info
{
    public $name; //String
    public $_postman_id; //String
    public $description; //String
    public $schema; //String
}

class Header
{
    public $key; //String
    public $value; //String
    public $description; //String
}

class Formdata
{
    public $key; //String
    public $value; //String
    public $type; //String
    public $disabled; //bool?
}
class Body

{
    public $mode; //String
    public $formdata; //array(Formdata)
}

class Request
{
    public $url; //String
    public $method; //String
    public $header; //array(Header)
    public $body; //Body
    public $description; //String
}

class Item
{
    public $name; //String
    public $request; //Request
    public $response; //array(Object)
}

class xibo
{
    public $variables; //array(Object)
    public $info; //Info
    public $item; //array(Item)
}

$json_data = json_encode((array) xibo);
print_r($json_data);

$URL = "HTTP://87.98.148.67/";    
$content = json_encode("mahdi");

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
       array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 201 ) {
    die("ersal nashod" . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}


curl_close($curl);

$response = json_decode($json_response, true);
echo $content;

@Sushiant, your question got many downvotes, because your code has many trivial mistakes. Don't worry about it. Everybody was nubies. Keep calm and learn.

My feedback is:

  1. Use $varName = new ClassName() for creating an object. The object is an instance of the class.
  2. Use json_encode for encode a variable to a json string.
  3. Use __construct in your classes
  4. Read any base PHP book or course.