本文整理汇总了PHP中Response::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::write方法的具体用法?PHP Response::write怎么用?PHP Response::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render(Request $request, Response $response)
{
ob_start();
$file = 'templates/' . $this->template . 'Template.php';
include_once $file;
$data = ob_get_clean();
$response->write($data);
}
示例2: display
/**
* Sets common parameters and arguments for all XSLT views and displays this view.
* @param Request $request Request
* @param Response $response Response
*/
public function display(Request $request, Response $response)
{
$this->proc->importStyleSheet($this->template);
if ($this->resource != null) {
$xml = Serializer::serialize($this->resource);
$this->doc->loadXML($xml);
}
$xml = $this->proc->transformToXML($this->doc);
$response->write($xml);
}
示例3: execute_request
function execute_request(Request $request, Response $response, $dispatchPath)
{
$dispatchList = (require $dispatchPath);
$result = Dispatcher::dispatch($dispatchList, $request);
if ($result[0] === false) {
$response->set_status_code(404);
$body = ErrorHandler::handleError(404, $request, 'Resource was not found');
$response->write($body);
return $response;
} else {
return \PHPMachine\DecisionCore::handleRequest($result[0], $request, $response);
}
}
示例4: delay_to
/**
* 等待一段时间后跳转到指定url
* 运行后仍然正常显示页面
* @param string $url 客户端跳转的URL绝对路径或者控制器路径<br>根目录控制器请开头补“/”
* @param integer $time 延时时间
* @param mixed $data 带着数据跳转
*/
public static function delay_to($url, $time = 5, $data = null)
{
$url = yyuc::url($url);
if ($time == 0) {
//纯JS跳转
Response::write("<script>location.href='" . $url . "';</script>", Mime::$htm);
die;
} else {
$tzpam = '';
if (is_array($data)) {
foreach ($data as $k => $v) {
$tzpam .= "<input type='hidden' name='" . $k . "' value='" . htmlentities($v) . "'/>";
}
} else {
$tzpam = "<input type='hidden' name='yyuc_pam' value='1'/>";
}
Response::write("<form action='" . $url . "' method='get' id='yyucform'>" . $tzpam . "</form><script>document.getElementById('yyucform').submit();</script>");
die;
}
}
示例5: strtotime
<?php
require_once 'inc/init.php';
$task_id = $_POST['task-status-id'];
$date = strtotime($_POST['task-status']);
$task = new Task();
$task->load('id = ?', [$task_id]);
$task->status = $_POST['task-status'];
if ($task->save()) {
Response::write('message', 'Task status updated');
} else {
Response::write('status', false);
Response::write('message', 'Task status failed to update.');
}
Response::output();
示例6: Task
<?php
require_once 'inc/init.php';
$task_id = $_GET['task-id'];
$task = new Task();
$task->load('id = ?', [$task_id]);
if ($task->delete()) {
Response::write('message', 'Task deleted');
} else {
Response::write('status', false);
Response::write('message', 'Task failed to delete.');
}
Response::output();
示例7: Model
<?php
if ('dbuniquecheck' == Request::get(1)) {
$dbdate = Request::json();
$m = new Model($dbdate[1]);
$query_arr = array($dbdate[2] => $dbdate[4]);
if (trim($dbdate[3]) != '') {
$query_arr['id@<>'] = trim($dbdate[3]);
}
if ($m->has($query_arr)) {
Response::write('no');
} else {
Response::write('ok');
}
} elseif ('getselvt' == Request::get(1)) {
$tn = String::decryption(Request::post('tn'));
$aw = String::decryption(Request::post('aw'));
$m = new Model($tn);
$array = $m->field('id,name')->where("pid='" . Request::post('pid') . "'" . $aw)->list_all_array();
Response::json($array);
}
示例8:
<?php
require_once 'inc/init.php';
Response::write('message', 'Welcome to ' . Config::read('application')['name']);
Response::output();
示例9: doGet
public function doGet(Request $request, Response $response)
{
$response->write("AUTRE " . $request->getAttribute('new') . " __ " . $request->getSession()->getAttribute("TEST"));
}
示例10: dirname
ob_start("ob_gzhandler");
} else {
ob_start();
}
//les managers ne renvoient QUE du json, on met donc le header de la réponse a jour
//on inclu l'autoloader
include dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoloader.php';
$manager = new Manager();
//on récupère la commande et la parse pour être executée
if (isset($_POST['command'])) {
$commands = explode(':', $_POST['command']);
$managerName = $commands[0];
$managerCommand = $commands[1];
//on supprime la commande de la variable globale, les managers n'ont pas a la connaitre et a l'utiliser
unset($_POST['command']);
//si on trouve la commande on l'execute
if ($manager->match($managerName, $managerCommand)) {
$manager->dispatch($_POST);
} else {
$response = json_encode(['result' => false, 'message' => "commande inexistante"]);
$objectResponse = new Response(404);
$objectResponse->write($response);
$objectResponse->send();
}
} else {
$response = json_encode(['result' => false, 'message' => "Variable POST command inexistante"]);
$objectResponse = new Response(404);
$objectResponse->write($response);
$objectResponse->send();
}
ob_end_clean();
示例11: fopen
*/
if ($argc > 1) {
$test = $argv[1];
require "{$test}.php";
if ($test == 'addressbook.proto') {
$fp = fopen('test.book', 'rb');
$m = new tutorial_AddressBook($fp);
var_dump($m);
fclose($fp);
} else {
if ($test == 'market.proto') {
//$fp = fopen('market2-in-1.dec', 'rb');
$fp = fopen('market2-in-2.dec', 'rb');
//$fp = fopen('temp', 'rb');
$m = new Response($fp);
echo $m;
//$mem = fopen('php://memory', 'wb');
$mem = fopen('temp', 'wb');
if ($mem === false) {
exit('Unable to open output stream');
}
$s = fstat($fp);
echo 'File size: ' . $s['size'] . "\n";
echo 'Guested size: ' . $m->size() . "\n";
$m->write($mem);
echo 'Write size: ' . ftell($mem) . "\n";
fclose($mem);
fclose($fp);
}
}
}
示例12: testBody
/**
* Test body and write
*
* Pre-conditions:
* Case A: Response body set to "Foo bar"
* Case B: Same response body is changed to "abc123"
* Case C: Same response body is appended with "xyz"
*
* Post-conditions:
* Case A: Response body is "Foo bar", and Content-Length = 7
* Case B: Response body is "abc123" and Content-Length = 6
* Case C: Response body is "abc123xyz" and Content-Length = 9
*/
public function testBody()
{
//Case A
$r1 = new Response();
$r1->body('Foo bar');
$this->assertEquals($r1->body(), 'Foo bar');
$this->assertEquals($r1->header('Content-Length'), 7);
//Case B
$r1->body('abc123');
$this->assertEquals($r1->body(), 'abc123');
$this->assertEquals($r1->header('Content-Length'), 6);
//Case C
$r1->write('xyz');
$this->assertEquals($r1->body(), 'abc123xyz');
$this->assertEquals($r1->header('Content-Length'), 9);
}
示例13: Task
<?php
require_once 'inc/init.php';
$task = new Task();
$tasks = $task->Find('1 = 1');
Response::write('data', $tasks);
Response::output();
示例14: quickResponse
/**
* @param int $status status HTTP de la réponse (404,200,500, etc)
* @param $content
* @param string $type
*/
public static function quickResponse($status, $content, $type = 'application/json')
{
$response = new Response($status, false, $type);
$response->write($content);
$response->send();
}
示例15: doPost
public function doPost(Request $pRequest, Response $pResponse)
{
$pResponse->write('TEST POST' . $pRequest->getParameter("toto"));
$pRequest->getSession()->setAttribute("TEST", $pRequest->getParameter("toto"));
}