当前位置: 首页>>代码示例>>PHP>>正文


PHP HttpResponse::setContentType方法代码示例

本文整理汇总了PHP中HttpResponse::setContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpResponse::setContentType方法的具体用法?PHP HttpResponse::setContentType怎么用?PHP HttpResponse::setContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpResponse的用法示例。


在下文中一共展示了HttpResponse::setContentType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_HttpResponse

/**
 * Test HttpResponse.
 */
function test_HttpResponse()
{
    HttpResponse::setCache(true);
    HttpResponse::setContentType('application/pdf');
    HttpResponse::setContentDisposition("test.pdf", false);
    HttpResponse::setFile('sheet.pdf');
    HttpResponse::send();
}
开发者ID:jkribeiro,项目名称:PHPHttpCompatibility,代码行数:11,代码来源:snippets.php

示例2: actionLongPoller

 public function actionLongPoller()
 {
     $model = new LongPoller();
     //$request = http_get_request_body();
     $request = json_encode(array("deviceID" => "90:C1:15:BC:97:4F", "orderNo" => "1"));
     $model->decodeStatusRequest($request);
     $model->checkStatus();
     $responseMsg = $model->generateResponse();
     HttpResponse::status(200);
     HttpResponse::setContentType('application/json');
     HttpResponse::setData($responseMsg);
     HttpResponse::send();
 }
开发者ID:nsawant942,项目名称:Canteen-Management-Software-System--Witwatersrand,代码行数:13,代码来源:MobileController.php

示例3: testGetContentType

 /**
  * @covers \http\HttpResponse::getContentType
  */
 public function testGetContentType()
 {
     $this->object->setContentType("text/xml");
     $this->assertEquals($this->object->getContentType(), "text/xml");
 }
开发者ID:elgervb,项目名称:php-http,代码行数:8,代码来源:HttpResponseTest.php

示例4: phpSerial

    $serial = new phpSerial();
    $serial->deviceSet("/dev/ttyACM0");
    $serial->confBaudRate(9600);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->deviceOpen();
    // arduino requires a 2 second delay in order to receive the message
    sleep(2);
    // Si c'est une request hi on allumera la led
    $data = $_GET["hi"];
    $serial->sendMessage($data);
    $read[$cnt] = $serial->readPort();
    while (substr($read[$cnt], -1, 1) != "a") {
        $cnt++;
        $read[$cnt] = $serial->readPort();
    }
    for ($i = 1; $i < $cnt + 1; $i++) {
        $rcv = $rcv . $read[$i];
    }
    $rcv = rtrim($rcv, "a");
    // Si c'est une request temperature on renvoiera la température (voir index.php pour le retour de valeur)
    // afficher température sur le bobox
    // Si c'est une request heure on affiche l'heure sur le bobox (pas besoin sur téléphone
    // Variation de lumière -> quelqun dans la piece ! notification téléphone ? a voir...
    HttpResponse::setCache(true);
    HttpResponse::setContentType('text/plain');
    HttpResponse::setData($rcv);
    HttpResponse::send();
    $serial->deviceClose();
}
开发者ID:ridergoster,项目名称:Boxobox,代码行数:31,代码来源:android.php

示例5: json_encode

<?php

require_once 'HTTP/Request2/Response.php';
//echo "Hello there you are now connected to the canteen web server <br />";
/*HttpResponse::status(200);
HttpResponse::setContentType('json');
//HttpResponse::setHeader('From', 'Lymber');
HttpResponse::setData($_POST);
HttpResponse::send();*/
$connection = Yii::app()->db;
$sql_select = 'SELECT *   FROM menu';
$command = $connection->createCommand($sql_select);
$menuData = $command->query();
$row = $menuData->readAll();
$json_string = json_encode(array("updated" => "false", 'menu:' => $row));
$headers = http_get_request_headers();
$result = http_get_request_body();
$decodeResult = json_decode($result);
HttpResponse::status(200);
HttpResponse::setContentType('application/json');
//HttpResponse::setHeader('From', 'Lymber');
HttpResponse::setData($json_string);
HttpResponse::send();
flush();
开发者ID:nsawant942,项目名称:Canteen-Management-Software-System--Witwatersrand,代码行数:24,代码来源:mobileTest.php

示例6:

<?php

// send 5000 bytes every 0.2 seconds, i.e. max ~25kByte/s
HttpResponse::setThrottleDelay(0.2);
HttpResponse::setBufferSize(5000);
HttpResponse::setCache(true);
HttpResponse::setContentType('application/x-zip');
HttpResponse::setFile('../archive.zip');
HttpResponse::send();
开发者ID:cheeepsan,项目名称:pear-core,代码行数:9,代码来源:Bandwidth_Throttling.php


注:本文中的HttpResponse::setContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。