Gets the current buffer contents and delete current output buffer. If this function returns more than 0 you are still inside a buffer. –It is that the ob_start, ob_get_clean don't work synchronously in the view process causes the problem. It then. Cette fonction vide le tampon de sortie sans l'envoyer au navigateur. If you just want to clean the buffer after starting output buffering with. If you still get errors, post them so we can figure it out. ini settings to reflect that. Yes it is possible. Share. php some other way. ob_end_clean (): bool. PHP ob_start() function works by catching all output to buffer and then implicitly output this buffer on script end. Usando ob_start le permite mantener el contenido en un buffer del lado del servidor hasta que esté listo para mostrarlo. d4rkpr1nc3. ob_start(); echo "Hello World!";. What ob_flush () does is delete everything in the buffer, but keeps the buffer itself so more data can be put into it after the ob_flush () call. I'm making my first plugin and I have a problem with displaying my shortcode. Parameters ¶ This function has no parameters. 0, UTF-8 is the default. If ob_flush() isn't called at the end of the app, the contents are automatically flushed, again. I need to display html source code form other php file. The ob_get_length () function returns the length of the topmost output buffer's contents in bytes. You have to give the id to report. We next include the template file. WordPress Shortcode with ob_start() This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. g. This is a bit harsh. 1 Answer Sorted by: 0 I was surprised by it as well, and the documentation could be more clear about this. PHP_OUTPUT_HANDLER_CLEANABLE - Calls to ob_clean(), ob_end_clean() and ob_get_clean() are permitted. Điều này giúp tránh việc gửi header hoặc thiết lập cookie trước khi nội dung được xuất ra. The function will be called when the output buffer is flushed (sent) or cleaned (with ob_flush(), ob_clean() or similar function) or when the output buffer is flushed to the browser at the end of the request. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_CLEANABLE flag. Tôi nhắc đến cơ chế cache vì các hàm ob_start(), ob_get_contents(), ob_clean(), ob_end_flush() sẽ hỗ trợ chúng ta trong quá trình thực hiện cơ chế này. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_FLUSHABLE flag. This is typically done using the ob_get_contents() and ob_end_clean() functions, respectively. Looks like half my answer was hidden due to my misplacement of the code formatting. Referral from July 3, 2014 . It is worth noting that if you have not assigned the output of this function to any variable, your code will not execute any action. 7. 0, 5, 7, 8) ob_get_clean 현재 버퍼 내용 및 삭제 출력 현재 버퍼 내용을 가져오고 기본적으로. You can then copy the contents of the internal buffer to a string and discard the buffer contents. It does not return the actual buffer output. It really depends on your use case. yes, it's visible now, thank you! but now I have another problem - my 'hello' shows in browser when I reload the page in admin bar, it's something with ob_start(); and ob_get_clean()? I made a mistake to localize it? –You break the process, if it is in a loop. Is there anyone get this problem and how to protect it index. So the browser doesn't receive header correctly. PHP may be configured to automatically create an output buffer when the script begins, which is why the buffer level may be 1 without calling ob_start (). Tôi có 1 ví dụ đơn giản như sau:W3Schools offers free online tutorials, references and exercises in all the major languages of the web. There's a limit to how much there can be buffered which by default is 4KB so you are hitting the maximum with your script. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. In general, if you have a straightforward pregnancy, you’ll see your prenatal. 3. ob_get_contents — Return the contents of the output buffer. You will need to store the new value somewhere because multiple instances of a script do not share variables just like that. Both functions clear the output buffer, turn off output buffering, and return the previous buffer value. 0, default_charset value is used as default. Try using output buffer like this : ob_start (); // your includes echo ob_get_clean (); Use this in all of your includes, and you will not get any errors. Before speaking about tags, you should understand how Twig works internally. ob_start and ob_get_clean() calls can be nested also. We then use the ob_get_clean() function to get. IE 'some text' is extracted from the buffer and prepared to be returned as per the requirement of the 'get' functionality. ob_get_clean () essentially executes both. Share. Share. ob_flush. 不过只要数据还没有真正发送到浏览器(严格来说是tcp buffer),那么是可以通过内置的ob_clean函数进行清空的。. PHP_OUTPUT_HANDLER_FLUSH when calling ob_flush() (but not ob_end_flush() or ob_get_flush()) PHP_OUTPUT_HANDLER_CLEAN when calling ob_clean(), ob_end_clean() and ob_get_clean() PHP_OUTPUT_HANDLER_WRITE automaticflush; Phases start, final and flush (resp. 'someOutput. This tells PHP to store any output generated by your script in a buffer. The ob_start () of the PHP Programming Language helps in enabling the Output Buffer/Buffering before any type of echoing in any type of some HTML content in the PHP script. All. Description ¶. Example Get your own PHP Server. it will work as you would use ob_start with no. The string will be captured and echoed. He just warns that you should really only use it if there is no other way as there are drawbacks which you. Everything works normally but the returned HTML structure is broken. Finally, you can print or save the contents. ob_end_flush () Deletes the topmost output buffer and outputs its contents. ), let's assume that we are looping through a set of users (as setup_userdata() fills the global variables of the currently logged in user and isn't useful for this task) and try to display. Handling ressources easily. I'm making my first plugin and I have a problem with displaying my shortcode. Descripción ¶. Note: This function is similar to ob_end_flush (), except that this function also returns the buffer as. Learn more about Labs Elementor page builder shortcode issue - unable to include external PHP file when using ob_start and ob_get_cleanI am working on a PHP script which involves me including several external PHP scripts via the "require_once()" method. index. I think in this case they mean the same thing. Definition and Usage. ). Facebook Twitter. To review, open the file in an editor that reveals hidden Unicode characters. ob_start(); ob_start('ob_gzhandler');ob_get_clean — Geçerli çıktı tamponun içeriğini döndürüp tamponu siler; ob_get_contents — Çıktı tamponunun içeriği ile döner; ob_get_flush — Çıktı tamponunu boşaltır, içeriğini bir dizge olarak döndürür ve çıktı tamponlamasını kapatır; ob_get_length — Çıktı tamponunundaki içeriğin uzunluğunu döndürürIf I try to use ob_get_content() instead of ob_get_clean() the table will be showed two times once in the post div and once at the bottom of the page. This system works "using set_error_handler"! The entire output (rendering html /php templates) is realised using "ob_start" and "ob_get_clean" - outputbuffer context. I am trying to get a list of all CSS/JS files and inline CSS on any give page. 既にob_start()で項で使用していましたが、ob_get_clean()は、ob_get_contents()とob_end_clean()と合体させたような便利な関数です。 1行でバッファと取得と既存のバッファの削除が同時に行える ため、汎用的に使用します。If you want, use output buffering with ob_start() and ob_get_clean() to get the output contents into a string which you can then use to fill out Content-Length. First follow what the codex says Shortcodes. Its output is rendered to the buffer. Here in this program, we have used OB _ START ( ) function to create the output buffer, and the OB _ END _ CLEAN ( ) function will be used to clear all the data of the created buffer; therefore, only the text outside the B _ START ( ) function and OB _ END _ CLEAN ( ) function will be displayed. So the browser doesn't receive header correctly. ob_start() enables turns on output buffering, ob_clean() - just cleans the buffer and leaves output buffering turned on, which is wrong! To turn it off, use ob_end_clean() instead of ob_clean(). PHP_OUTPUT_HANDLER_FLUSHABLE - Calls to. Example #1 A simple ob_get_length() example. php . get_the_title() and get_the_post_thumbnail(). ini or calling ob_end_clean() or ob_end_flush() at the start of the script removes this necessity. 2. Learn more about CollectivesFilter hooks in WordPress provide a very powerful way to “alter” the output of functions. 1. The function you're probably looking for is ob_get_clean. Other functions are all working fine e. The code from your question has this undesired effect:Here's my problem. ob_get_clean () básicamente ejecuta ob_get_contents () y ob_end_clean () . 2. 現在のバッファの中身を取得し、出力バッファを削除します。 ob_get_clean() は、基本的に ob_get_contents() および ob_end_clean() を同時に実行するのと同じです。 出力バッファを開始するときに、 ob_start() で PHP_OUTPUT_HANDLER_CLEANABLE および PHP_OUTPUT_HANDLER_REMOVABLE フラグを指定する必要があります。Mar 26, 2011 at 11:46. An optional output_callback function may be specified. However, the problem is, it parses the PHP include() and stores only the HTML content. This function will send the contents of the output buffer (if any). ob_flush (): bool. Once returns some information and I am trying to get this to be accessible in my second function but this is currently empty/ Here is my first function code:ob_start enables output buffering so nothing gets sent to the browser. They are : callback parameter, Chunk Size. Le tampon de sortie doit avoir été démarré avec la fonction ob_start () et le drapeau PHP_OUTPUT_HANDLER_CLEANABLE . asked:Two problems. Also, there is another function ob_get_contents() that grabs all of the data gathered since we called ob_start. You switched accounts on another tab or window. flush() ob_clean() ob_end_clean() ob_end_flush() ob_flush() ob_get_clean() ob_get_contents() ob_get_flush() ob_get_length() ob_get_level() ob_gzhandler() ob_implicit_flush() ob_list_handlers() ob_start() output_add_rewrite_var() output_reset_rewrite_vars() Description ¶ ob_get_contents (): string|false Gets the contents of the output buffer without clearing it. djjjozsi, thank you for your attempt but your code just echoed the ranking. The print data is. to wit: given: ob_start(); echo 'before'; ob_start(); echo 'second'; Viewed 2k times. ) I started thinking about it after reading. file_get_contents is for opening and reading a file as text which would get you the source of the file. if you call ob_end_clean() after ob_start("ob_gzhandler"), the "Content-Encoding: gzip" header will still get sent (assuming the browser supports the encoding). <?php // 출력 버퍼링을 초기화 합니다. It shows in the top all the time but I have read some about ob_start(); and trying to use it but the shortcode just returns nothing. In PHP 8. Before you downvote, the reason I added this as an answer and not a comment is I don't have sufficient reputation to comment. I've choosed to use ob_start('callback') and ob_end_flush() at the end of the page. ob_get_length () -출력 버퍼의 길이를 반환. The first function I’m going to cover is ob_end_clean(). ob函数用于web场景,比如: 脚本未结束前(可能脚本执行时间较长),先输出部分内容La función ob_get_clean() es una función PHP incorporada que se utiliza para limpiar o eliminar el búfer de salida actual. 4 ob_* functions. ini or calling ob_end_clean() or ob_end_flush() at the start of the script removes this necessity. The problem is that sometimes I need the contents of the PHP file 20 - 30 times in 1 call. g in your shortcode handler. It shows in the top all the time but I have read some about ob_start(); and trying to use it but the shortcode just ret. – Chris Carson. Álvaro. Otherwise ob_get_clean() will not work. ob_get_clean — Get current buffer contents and delete current output buffer. Returns all content captured by ob_start() ob_end_clean() Empties the output buffer and turns it off for the current nesting level: ob_get_clean() Triggers both ob_get_contents() and ob_end_clean() ob_get_level() Returns the current nesting level of the output buffer: ob_flush() Flush the content buffer and send it to the browser without ending. ob_start no almacena en el buffer las cabeceras, sino el contenido. to copy the output buffer to a string for further manipulation and then silently discard the buffer with ob_end_clean(), the output buffer is never "flushed" and as a result, the ob. 1. Here is the modified version of the output to be displayed as per your requirement. I want to build a cache system for a e-commerce platform. php having a lot of ob_start, ob_end_cleans with function calls in between. Otherwise ob_clean () will not work. Even in the examples. The ob_get_length () function returns the length of the topmost output buffer's contents in bytes. php it should replace a string with the output of links. I am trying to get the browser timezone via JavaScript and capture it in a php variable with ob_start() and ob_get_clean. Here are the functions you could use: ob_get_clean. Below is the sample code. Steps: Send new value to phpScript1 with clientScript1. I have a script that echo out content in a php script and resulting in a very large file, e. My problem is that I want to keep the shopping cart live so I don't want to cache it. Stack Overflow is leveraging AI to summarize the most relevant questions and answers from the community, with the option to ask follow-up questions in a conversational format. I'm generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. )PHP output buffering is an efficient way of giving an output to the end-user by keeping the data into a buffer before putting it to the browser it keeps the data on hold and then it assigns a variable to make the reference as it gives programmers the ability to change and manipulate it accordingly for the end-user with proper requirement. Example: ob_start(); print "foo"; // This never prints because ob_end_clean just empties ob_end_clean(); // the buffer and never prints or returns anything. ob_get_clean() combines my use of ob_get_contents() and ob_end_clean(). La función ob_get_clean() es la combinación de ob_get_contents() y ob_end_clean(). What is the ob_get_level() Function? The ob_get_level() function is a PHP built-in function that allows you to get the current level of output buffering. + add a note. The output buffering functions are also useful in hackery to coerce functions that only print to return strings, ie. Disabling output_buffering via php. After creating a custom shortcode and inserting it into any page position, it also shows up at the top of the page, but only in. Hi again! I made it private because I was under the assumption that no one would need it, and I was planning to rewrite the output API — this probably won’t happen anytime soon. – bjauy May 21, 2012 at 7:41 Description ¶ ob_get_clean (): string|false Gets the current buffer contents and delete current output buffer. ob_get_flush — Flush the output buffer, return it as a string and turn off output buffering. According to the manual,. Probably you are using a buffering function in output buffering callback which isn't possible as mentioned in php ob_start output_callback documentation. 3. First my syntax is parsed and reformatted. However a few years ago I was having errors that required me call both get_clean and flush. The two functions you can use for this are ob_start () and ob_get_contents (). Clean up after yourself. Renders a JS template for the content of date time control. Jun 18, 2014 at 17:48. ob_clean () Deletes all of the content from the topmost output buffer. Actually, we can use type regulation - intval (ob_get_contents ()), for cheking On/Off output buffering, but it lays the possible problems in the future. Sorry about that. ob_list_handlers — List all output handlers in use. Since the 2 statements follow eachother here, you're not intercepting anything at all. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_CLEANABLE and PHP_OUTPUT_HANDLER_REMOVABLE flags. But before returning the code to the caller, do the necessary text substitution. Using. The function will be called when the output buffer is flushed (sent) or cleaned (with ob_flush(), ob_clean() or similar function) or when the output buffer is flushed to the browser at the. Asking for help, clarification, or responding to other answers. The string includes specials tags like the following as well as normal text + images. php"; include "view/footer. Next time the browser send request, the session id. If you want to further process the buffer's contents you have to call ob_get_contents () before ob_end_clean () as the buffer contents are discarded when ob_end_clean () is called. Going by the comments of OP, I'm going to assume OP wants a timer on the command line and presume the <br> was meant to convey a newline. ob_get_clean (): string|false. 6. Add a comment | 6 Specifically to Test code or tested code did not (only) close its own output buffers. Get early access and see previews of new features. You would call this function last in the output buffering process because if you need to get or send the content stored in the output buffer, calling ob_clean() would clean the contents of the output buffer and there won't be any content to receive or send. Successive calls to ob_start() create "nested" buffering contexts; ob_get_clean() fetches and clears the current context, but does not terminate it, so a second call to ob_start() creates a second nested buffering context. x and PHP 5. I am using ob_start() and ob_get_contents() to setup a cache. php in the file where you want to convert html to pdf. It's useful in cases where you may need to filter some output, or you're using a PHP method (such as var_dump) that writes output. It is based on FPDF and HTML2FPDF, with a number of. Find centralized, trusted content and collaborate around the technologies you use most. If this function returns more than 0 you are still inside a buffer. (The same goes for your call to core_function). Most known loaders are Twig_Loader_Filesystem to open twig code from a file, and Twig_Loader_Array to get twig code directly from a string. ob_get_clean () essentially executes both ob_get_contents () and ob_end_clean () . This function does not destroy the output buffer like ob_end_flush. ob_end_clean() returns true or false (in your case, true, or 1). Sintaxis: string|false ob_get_clean();ob_start(); debug_print_backtrace(); error_log(ob_get_clean()); This uses PHP’s built-in buffer as well as the previously mentioned error_log() function to provide insight as to the source of errors produced by an application. Jul 28, 2020 at 7:36. In this article, we will take an in-depth look at the ob_get_clean() function and its usage. ob_get_length — Retorna o tamanho do buffer de saída. php'; // echo 100MB data $data = ob_get_clean(); file_put_contents($path, $data); Are there any easy way to re-write the. ob_get_status() - Trả về thông tin của các bộ đệm đầu ra. After this you can move go on - even with only flush () instead of ob_flush (). php some other way. Two problems. ob_get_length — Return the length of the output buffer. You would also need chunked headers – mousetail. net: If a user uses ob_gzhandler or similar with ob_start(), the function order is important for proper output. When you write your scripts, output buffering can be turned on by calling the ob_start. 2. The ob_start() function creates an output buffer. This new value can be stored in a file, database or as a session variable, etc. So, fortunatly there is some php tools that do interpret the page and can fetch any sub files. to determine the output buffer level at the start and end of the affected test. Instead of using strip_tags() or any clever trick, I just worked my way backwards from everything that the original function did. Delete an output buffer without sending its contents to the browser: <?php. php. Reload to refresh your session. I have to use ob_start(); and ob_get_clean(); for this to work. The thing is that sleep() than echo(), than sleep() again, than echo() again, etc, etc. ob_get_flush() flushes the output buffer, return it as a string and turns off output buffering. Using ob_start() and ob_get_clean() allows you to return HTML code from the shortcode. 2) The function return TRUE on success and FALSE on failure. 5. Share. Definition and Usage. I also want to be able to show the user the XML before hand. Share. the *_clean variants just empty the buffer, whereas *_flush functions print what is in the buffer (send the contents to the output buffer). Capture HTML output. Cette fonction ne détruit pas le contenu du tampon de sortie comme peut le faire ob_end_clean () . I must say i discovered that the problem is something between the two scripts (server_status and ranking) and not with ranking. then it's noted there "The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_CLEANABLE flag. The problem with this is, that you have “ob_get_clean” outside the “if”, where “ob_start” is. For example, ob_gzhandler must be registered before starting the session. This can be done with the ob_start() function, which causes the output to be stored in an internal buffer. It all works fine on my Windows desktop test machine, but when I run it on the live host ob_get_contents() is empty. A callback function can be passed in to do processing on the contents of the buffer before it gets flushed from the buffer. 1. Gets the current buffer contents and delete current output buffer. You can't include a query string on the include file. Examples. 5 Answers. We then include the file which will execute PHP normally. Take a look at very simple example for PHP 5. . ob_flush (): bool. php output. . But let's suppose you can, is the first thing that happens in this class always an ajax request? If not, then you still haven't initiated ob_start(). We initialize the Dompdf class, then we pass it the HTML page (the page. Easiest way is with multiple ob_start(), ob_get_clean() calls that each log some portion of the request. Actually, we can use type regulation - intval (ob_get_contents ()), for cheking On/Off output buffering, but it lays the possible problems in the future. Add a comment. 3. I would like to know if there is a way for the master script (the one including the others) to tell whether or not the processed output from included script has generated any content. Store new value with phpScript1. ob_clean() This function removes what is stored in the output buffer. . One thing I have noticed here is sleep() function in combination with ob_start() and - THERE IS NO - ob_start() anywhere in the full code example, yet there is flush() and ob_flush(). How to Use the ob_get_level() Function. ob_gzhandler — ob_start callback function to gzip output buffer. Unless the string is returned it will not be displayed. SpaceX reached several milestones in its Starship rocket system’s second integrated test flight before losing the booster and spacecraft. If I remove the ob_end_clean(); the output is hi hi. This can be done with the ob_start() function, which causes the output to be stored in an internal buffer. Diese Funktion besitzt keine Parameter. 4 ob_* functions. You may execute ob_end_clean() to discard (clean) buffer. answered Oct 2, 2013 at 14:38. One way of outputting a webpage to mPDF without re-writing your scripts too much, is to buffer the output: MpdfMpdf () - Initialise an instance of mPDF class, and specify configuration. php. ob_get_length — Return the length of the output buffer. ob_get_clean(); Technical Details. g. Is it possible to pause the output buffering in php so that I could skip the buffering on the table headers and resume again at the beginning of the actual content?Once ob_end_flush(), we need to recreate a fresh buffer again, if required. Find centralized, trusted content and collaborate around the technologies you use most. British Columbia welcomes semi-skilled foreign nationals with in-demand jobs in Canada’s tourism,. To do this correctly you should be doing ob_start() after ob_get_clean() because ob_get_clean() gets the current buffer contents and delete the current output buffer. If you want to capture the output, wrap it in ob_start() and ob_get_clean()When using PHP as the back-end for SSE (Server Sent Events) and similar server streaming solutions, I have been using the @ob_flush();@flush() idiom to make sure the data gets spat out immediately. So, fortunatly there is some php tools that do interpret the page and can fetch any sub files. Im novice so i dont understand what this doing. The ob_start () function don’t. ob_end_clean (): bool. output_compres. It’s actually very simple: ob_start(); // start output. The ob_get_clean() function is the combination of both ob_get_contents() and ob_end_clean(). ob_start (), ob_get_clean. output buffering works by intercepting all output; so any output that comes before ob_start() will not be included. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_FLUSHABLE flag. The ob_get_flush () function outputs the contents of the topmost output buffer, returns the contents and the deletes the buffer. There is a work-around for the situation you need to get length of the gz-ed buffer. txt which is the last line of that file. html. El búfer de salida debe estar iniciado por ob_start () con el indicador PHP_OUTPUT_HANDLER_CLEANABLE Si no, ob_get_clean () no funcionará. Description ¶. I manage to update cart quantity with filter woocommerce_add_to_cart_fragments like this:I just got done creating the composer library for this very purpose. But you also need to end and retrieve the contents of the buffer as well. Edson's code works because the output buffer did not automatically get flushed because it doesn't exceed the buffer size (and the script isn't terminated obviously before the. Definition and Usage. This way I can use the function requireToVar with additional parameters also and I can use my template without a problem insted of writing some content into index. ob_get_clean() silently discards the buffer contents. creates true color GD image object with specified width & height. Syntax: The ob_get_clean() function is a built-in function in PHP that allows you to get the contents of the output buffer and turn off output buffering. g. net for ob_clean(). So the first thing in your script should be ob_start (). but without using ob_get_clean(); and shortcode, i can get output like this :. I found out that the problem can be fixed by either using return instead of echo, or by using output buffering: (ob_start () / ob_get_contents ()) Unfortunately my coding skills are not what I would like them to be. This will return the length of the contents in the output buffer, in bytes. If you just want to clean the buffer after starting output buffering with. "; We start output buffering using ob_start () to capture the output of the PHP code that follows. To close all layers an prevent problems, do the following: while (@ob_end_clean ()) { // do nothing } This will delete all layers. 1. What is the ob_get_contents() Function?Lo tienes al revés. This is why it is necessary to use ob_flush() as well as flush(). First, you can't call a PHP page like that using include_once - the query string will be ignored. I'm trying to find a catch-all filter that gives me one last crack at modifying the final markup in its entirety before output. Learn more about CollectivesCollectives™ on Stack Overflow. From PHP manual: PHP_OUTPUT_HANDLER_CLEANABLE const control access to functions: ob_clean (), ob_end_clean (), and ob_get_clean (). ob_get_level() - Cho biết hiện đang có bao nhiêu bộ đệm đầu ra trên ngăn xếp. 참고 See also header() and setcookie() . Example 2:After doing a little investigating, I noticed this line in the session_start() manual at PHP. I manage to update cart quantity with filter woocommerce_add_to_cart_fragments like this:I just got done creating the composer library for this very purpose. Since the 2 statements follow eachother here, you're not intercepting anything at all. I just saw it isn't plain PHP but Laravel. ob_start (); echo "Hello All!"; ob_end_clean (); echo "A Debug Statement"; Output. txt file contain a new line - " " at the end, except for the data10. You need to comment out only the_time function, not the entire line, or else you will get errors. ob_clean (): bool. Take a look at very simple example for PHP 5. if you call ob_end_clean() after ob_start("ob_gzhandler"), the "Content-Encoding: gzip" header will still get sent (assuming the browser supports the encoding). s. About the author. By using the above primary functions of PHP output buffering, we are going. full example . ob_get_clean () essentially executes both ob_get_contents () and ob_end_clean () . The output may be caught by another output buffer or, if there are no other output buffers, sent directly to the browser. This function does not destroy the output buffer like ob_end_clean () does. PHP may be configured to automatically create an output buffer when the script begins, which is why the buffer level may be 1 without calling ob_start (). If you want to capture instead of echoing, you should use ob_get_clean () – kijin. Aug 2, 2013Description ¶ ob_get_contents (): string|false Gets the contents of the output buffer without clearing it. Parameter-Liste. ob_get_contents — Return the contents of the output buffer. We hope this article has been informative and useful in understanding the ob_start () function in PHP.