output-buffering

PHP Output buffering on the command line

大城市里の小女人 提交于 2019-12-11 02:39:33
问题 I have a PHP script that I want to run on the command line. This script, among other things, needs to load a PHP file that contains both PHP and HTML content and get the rendered output from that file. This code does exactly what I need, but not when run from the command line: <?php // ... if(file_exists($content_file)) { ob_start(); include($content_file); $content = ob_get_contents(); ob_end_clean(); } ?> When run in the browser, my script gets the rendered output of the PHP file via

Powershell: How to capture output from the host

本秂侑毒 提交于 2019-12-10 15:45:13
问题 I am using powershell to automate some tasks related to checking out/merging in TFS. When I call tf get * /recurse I get a bunch of data scrolling by about the files that are getting checked out. The last line generated by this command (assuming its success) is one telling the checkin number. I would like to parse this out so it can be used later on in my script. I know that I can do something like $getOutput = tf get * /recurse but then the output is suppressed entirely and I want the output

Output buffering vs. storing content into variable in PHP

巧了我就是萌 提交于 2019-12-10 13:49:02
问题 I don't know exactly how output buffering works but as far as know it stores content into some internal variable. Regarding this, what is the difference of not using output buffering and storing content in my own local variable instead and than echo it at the end of script? Example with output buffering: <?php ob_start(); echo "html page goes here"; ob_end_flush(); ?> And example without using output buffering: <?php $html = "html page goes here"; echo $html; ?> What is the difference? 回答1:

session_regenerate_id() - headers already sent in unit testing Yii controller

╄→гoц情女王★ 提交于 2019-12-10 13:31:15
问题 I'm trying to unit-test my controller (Yii framework). /** * @dataProvider provider */ public function testActionEdit_view_login($controller){ $user = new CWebUser; $user->id = 978; $identity = new UserIdentity('me@test.com', '123456'); $user->login($identity); $controller->actionEdit(); $output = ob_get_contents(); assertContains('Add/Change Profile Picture:', $output); assertContains('bio', $output); assertContains('specialties', $output); assertContains('change login', $output);

PHP Output Buffering Check? [duplicate]

心不动则不痛 提交于 2019-12-10 10:34:57
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: PHP - How Detect if Output Buffering is Turned On How can I check in PHP if output_buffering is set to On? I have to troubleshoot a site and I have no access to the hosting panel. Something like: if(output_buffering == 'On') { echo 'It is On'; } else { echo 'It is NOT On'; } Thank you! 回答1: You should be able to do this with ini_get(). I didn't test it, but I am pretty sure it will suit your needs since ini_get(

“headers already sent” Error returned during PHPUnit tests

白昼怎懂夜的黑 提交于 2019-12-09 15:42:04
问题 I'm testing a suite of REST web services with PHPUnit. We're using output buffering in order to gzip-encode the responses. When I run a test for the service with PHPUnit, I'm getting the error: Cannot modify header information - headers already sent by (output started at /home/dotcloud/php-env/share/php/PHPUnit/Util/Printer.php:172) It's complaining at the point that my code echo's the output to the browser... I was able to work around this temporarily by adding an ob_start() call at the top

whats the difference between ob_flush and ob_end_flush?

风格不统一 提交于 2019-12-09 10:23:21
问题 i am confused about the PHP functions ob_flush() and ob_end_flush() . About the function ob_flush the manual says The buffer contents are discarded after ob_flush() is called.This function does not destroy the output buffer like ob_end_flush() does. i am confused about the words discarded and destroyed here . Even if the buffer contents are discarded in case of ob_flush() they cant be accessed and even if they are destroyed as in case of ob_end_flush() they cant be accessed. Then whats the

Cannot use output buffering in output buffering display handlers

冷暖自知 提交于 2019-12-08 15:58:35
问题 I've reinstalled Apache, and switched from PHP 5.3 to 5.6. Everything works, except I get this error, when calling ob_start() : Cannot use output buffering in output buffering display handlers I tried to enable output buffering in PHP, but I still get this error: output_buffering = 4096 回答1: Probably you are using a buffering function in output buffering callback which isn't possible as mentioned in php ob_start output_callback documentation. If not it should be the output-handler you used,

What is the purpose of the SerialPort write buffer?

。_饼干妹妹 提交于 2019-12-07 17:00:36
问题 From outside SerialPort object, it seems to make no difference what the size of the write buffer is, and whether or not it is full. Using synchronous writing, the write method blocks until all the data has been sent and the buffer is empty. Using async writing, the data is queued and the program continues on going. The callback method is not called until the write operation is completed and the data is out of the buffer. The behavior of the serialport object seems to be the same regardless of

buffering behaviour of stdout in c

时光怂恿深爱的人放手 提交于 2019-12-07 15:24:42
问题 When I run the first code and press ctrl-c immediately there will be no 45 written out to the file. But when I run the second code, I do get 45 . I couldn't come to the reason why this behavior happens in the below code? If stdout is line buffered shouldn't output come after I enter a character? What am I missing? First code: #include<stdio.h> #include<stdlib.h> int main() { FILE *fp=stdout; fp=fopen("myfile","w"); fprintf(fp,"%d",45); getchar(); // return 0; } Second code: #include<stdio.h>