使用ob_start()把輸出那同輸出到緩沖區(qū),而不是到瀏覽器。然后用ob_get_contents得到緩沖區(qū)的數(shù)據(jù)。ob_start()在服務(wù)器打開一個(gè)緩沖區(qū)來保存所有的輸出。所以在任何時(shí)候 " /> 欧美在线一,激情文学亚洲,色综合a怡红院怡红院首页

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

關(guān)于ob_get_contents(),ob_end_clean(),ob_start(),的具體用法詳解

ob_get_contents();
ob_end_clean();
ob_start()

使用ob_start()把輸出那同輸出到緩沖區(qū),而不是到瀏覽器。
然后用ob_get_contents得到緩沖區(qū)的數(shù)據(jù)。
ob_start()在服務(wù)器打開一個(gè)緩沖區(qū)來保存所有的輸出。所以在任何時(shí)候使用echo ,輸出都將被加入緩沖區(qū)中,直到程序運(yùn)行結(jié)束或者使用ob_flush()來結(jié)束。然后在服務(wù)器中緩沖區(qū)的內(nèi)容才會(huì)發(fā)送到瀏覽器,由瀏覽器來解析顯示。

函數(shù)ob_end_clean 會(huì)清除緩沖區(qū)的內(nèi)容,并將緩沖區(qū)關(guān)閉,但不會(huì)輸出內(nèi)容。
此時(shí)得用一個(gè)函數(shù)ob_get_contents()在ob_end_clean()前面來獲得緩沖區(qū)的內(nèi)容。
這樣的話,能將在執(zhí)行ob_end_clean()前把內(nèi)容保存到一個(gè)變量中,然后在ob_end_clean()后面對(duì)這個(gè)變量做操作。

這是EG:
ob_start(); // buf1
echo ' multiple ';
ob_start(); // buf2
echo ' buffers work ';
$buf2 = ob_get_contents();
ob_end_clean();
$buf1 = ob_get_contents();
ob_end_clean();
echo $buf1;
echo '<br/>';
echo $buf2;
ob_get_contents

(php 4, php 5)
ob_get_contents -- Return the contents of the output buffer
Description
string ob_get_contents ( void )
This will return the contents of the output buffer or FALSE, if output buffering isn't active.
See also ob_start() and ob_get_length().
if you use ob_start with a callback function as a parameter, and that function changes ob string (as in example in manual) don't expect that ob_get_contents will return changed ob.
it will work as you would use ob_start with no parameter at all. So don't be confused.
transfer image, another method (alternative to fsockopen or function socket) :
server(192.168.0.1)
makeimage.php
...........
...........
$nameimage="xxxx.jpg"
$comand=exec("plotvelocity.sh $nameimage $paramater1 $paramater2");
ob_start();
readfile($nameimage);
$image_data = ob_get_contents();
ob_end_clean();
echo $image_data;
unlink($nameimage);
Client (192.168.0.2)
$bild="images/newimage2.gif";
$host="192.168.0.1";
$url=file_get_contents("http://$host/makeimage.php?$querystring");
$fp = fopen("$bild", 'wb');
fwrite($fp, $url);
fclose($fp);
echo '<img src="'.$bild.'">';
naturally you can transfer whichever thing and not only images
ob_get_clean

(php 4 >= 4.3.0, php 5)
ob_get_clean -- Get current buffer contents and delete current output buffer
Description
string ob_get_clean ( void )
This will return the contents of the output buffer and end output buffering. If output buffering isn't active then FALSE is returned. ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean().

例子 1. A simple ob_get_clean() example
復(fù)制代碼 代碼如下:
<?php
ob_start();
echo "Hello World";
$out = ob_get_clean();
$out = strtolower($out);
var_dump($out);
?>

Our example will output: string(11) "hello world"
See also ob_start() and ob_get_contents().
Notice that the function beneath does not catch errors, so throw in an @ before those ob_* calls
Running php4 < 4.3.0, you can simply add the following to use the function anyway:
復(fù)制代碼 代碼如下:
<?php
if (!function_exists("ob_get_clean")) {
function ob_get_clean() {
$ob_contents = ob_get_contents();
ob_end_clean();
return $ob_contents;
}
}
?>

php技術(shù)關(guān)于ob_get_contents(),ob_end_clean(),ob_start(),的具體用法詳解,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久中文字幕久久久久 | 怡红院在线观看精品 | 狠狠久久亚洲欧美专区 | 久久国产精品-久久精品 | 手机在线观看黄色网址 | 国产欧美在线观看精品一区二区 | 国产成人资源 | 欧美色欧美亚洲高清在线观看 | 天天久久狠狠色综合 | 华人亚洲欧美精品国产 | 狠狠色香婷婷久久亚洲精品 | 国产精品高清视亚洲一区二区 | 欧美日韩亚洲国产一区二区三区 | 日韩在线视频第一页 | 五月天婷婷影院 | 欧美一区二区三区gg高清影视 | 新版天堂资源中文8在线 | 天天天天干 | 国产成人精品高清免费 | 色视频网址 | 婷婷在线五月 | 亚洲一区二区三区福利在线 | 青草国产视频 | 欧美人与禽片免播放 | 精品无人区乱码麻豆1区2区 | 好吊日在线 | 国产欧美精品一区二区色综合 | 色婷婷综合缴情综六月 | 欧美日韩中文一区二区三区 | 加勒比免费视频 | 在线播放亚洲视频 | 国产极品麻豆91在线 | 亚洲欧洲专线一区 | 亚洲国产成人综合精品2020 | 加勒比色久综合在线 | 日本一区二区三区四区五区 | 精品久久久久久中文 | 岛国福利视频 | 青青草国产精品久久久久 | 久久综合爱 | 国产高清www免费视频 |