header('Content-Type: text/html'); self::setContent('Hello World!
');
header('Content-Type: application/json'); $data = ['name' => 'John', 'age' => 30]; self::setContent(json_encode($data));In this example, we are setting the content type to JSON and then setting the content of the object instance to a JSON string containing an associative array with keys `name` and `age`. This could be used to send data to a client as a JSON response. Package library: This method belongs to the Symfony\Component\HttpFoundation\Response class, which is part of the Symfony HTTP Foundation library.