PHP???????
???????????? ???????[ 2013/5/6 15:00:07 ] ????????
?????????????????????????????Щ??о????κβ?????????????????±?д???????????Щ???????????????д?????????????????в???????????????????飬??????????????
???????????Щ?????????????????????????磺????????????????????±?д?????????????????г??????????y??е???????
??????PHP?????У????????????????д?????index.php??script.php????е????Щ.php??????????????????????????????????????????????????Web????????????
???????????
????????????PHP??????????????????HTTP????????鷵??????(response)????????????????????????????????????????response??request??????????????(content)???????????????????(header)????????
???????????????????????????????????????????????????????????????????????????ó???????????
??????????У?????????????????е?PHP?????????д?????????°????ū?ò???????????????PHP??????????????????????PHP????????ЩС???????
??????ν????????С???????include??require????????????б??????????????????????????÷???????磺??header()д??$object->header()??
???????????????????????????????????????????????????????????????????????????????С?
???????崠??
?????????????HTTP??????????????$_GET??$_POST????????$_SERVER??header??
????????????????????response??body???????ob_start()??ob_get_clean()???????????????????echo()????<?php????????buffer(????????)??
???????????????????PHP??????????????????????????£???????????????????????ob_*????????
?????????????????????????????????????????????????Χ????????????????á????磺
????1?????????????????????????????????????????$connection????????????????
????2?????????PHP?????ú???????ü??????????????磺header()д??$this->header()??
???????????
???????????????????????????????嵽????У??????????????
<?php
class ForumPosting
{
private $headers = array();
public function handleRequest($postRequest)
{
$_POST = $postRequest;
$connection = $this->getAConnection();
ob_start();
include 'forum/post_new_copy.php';
$content = ob_get_clean();
return array(
'content' => $content??
'headers' => $this->headers
);
}
private function header($headerLine)
{
$this->headers[] = $headerLine;
}
...
}
???????????????????
public function testANewPostIsCreated()
{
$action = new ForumPosting();
$response = $action->handleRequest(array(
'id_thread' => 42??
'text' => 'Hello?? world'??
...
));
$this->assertEquals('...'?? $response['content']);
$this->assertContains('Content-type: text/html'?? $response['headers']);
}
????????
?????????????????????????????д???????????????????????????????PHP?????????????????????????
???????????????????????handleRequest()???????滻??????????????????????д?????????????????????д??????????????????????????????
????????????http://my.oschina.net/liux/blog/56268
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11