ob_get_clean. ob_get_clean(): Three Birds, One Stone. ob_get_clean

 
 ob_get_clean(): Three Birds, One Stoneob_get_clean Code Examples

The ob_get_clean() function returns the contents of the output buffer and then deletes the contents from the buffer. return ob_get_clean(); Share. The output buffer must be started by ob_start with PHP_OUTPUT_HANDLER_CLEANABLE and. ob_get_clean — Get current buffer contents and delete current output buffer. 1. g. The reason I'm not voting for ob_get_clean is because I've had times when other developers get confused regarding what is really going on, the function name doesn't really state that the output buffering will end after it's call. The reason I'm not voting for ob_get_clean is because I've had times when other developers get confused regarding what is really going on, the function name doesn't really state that the output buffering will end after it's call. // Turn on implicit flushing. ob_end_clean (): bool. Once output has started, the only way to redirect is through JavaScript, you cannot use PHP. This function will send the contents of the output buffer (if any). ob_flush() - Vaciar (enviar) el búfer de salida ob_end_flush() - Volcar (enviar) el búfer de salida y deshabilitar el almacenamiento en el mismo ob_end_clean() - Limpiar (eliminar) el búfer de salida y deshabilitar el almacenamiento en el mismo +add a note現在のバッファの中身を取得し、出力バッファを削除します。 ob_get_clean() は、基本的に ob_get_contents() および ob_end_clean() を同時に実行するのと同じです。 出力バッファを開始するときに、 ob_start() で PHP_OUTPUT_HANDLER_CLEANABLE フラグを指定する必要があります。I know that this is an old question but I wanted to write my answer for visual learners. The ob_start () function starts PHP’s output buffering. The ob_get_contents() function is a useful tool for getting the contents of the output buffer in. Otherwise. Conclusion. 참고 See also header() and setcookie() . add_filter('wp_nav_menu_items', 'crunchify_add_login_logout_menu', 10, 2);2. Oct 30, 2010 at 20:39. ob_clean () Deletes all of the content from the topmost output buffer. ob_get_clean () exécute successivement ob_get_contents () et ob_end_clean. 1 Answer Sorted by: 9 This will return the same as your example given : ob_start (); echo 'custom code'; echo 'another line of custom code'; echo 'more code'; return. Teams. Output buffering should be taking place inside your shortcode callback. First, you can't call a PHP page like that using include_once - the query string will be ignored. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. We can take the previous example to learn how to subsequent buffers into a stack. This would seem evidence that ob_clean, isn't actually doing what the codex suggest. . IE 'some text' is extracted from the buffer and prepared to be returned as per the requirement of the 'get' functionality. Cette fonction vide le tampon de sortie sans l'envoyer au navigateur. ob_clean ():. Here I’ve just added style: float=right. imagejpeg outputs an image. คำสั่ง ob_start จะเป็นคำสั่งที่บอก PHP ว่าต่อจากนี้ไปอะไรที่ echo ออกมาให้เอาไปเก็บไว้ใน cache ก่อนนะ ส่วนคำสั่ง ob_get_clean เป็นคำสั่งบอกว่า. Table of Contents flush — 출력 버퍼를 비웁니다 ob_clean — 출력 버퍼를 지웁니다 ob_end_clean — 출력 버퍼를 지우고 출력 버퍼링을 종료 ob_end_flush — 출력 버퍼를 전송하고 출력 버퍼링을 종료 ob_flush — 출력 버퍼를 전송합니다 ob_get_clean — 현재 버퍼. ob_get_clean() return the buffer and empty it. ob_get_clean, only works twice. I was trying to debug my code using error_log() and I discovered that ob_get_clean() also truncates the error_log() buffer right in the middle of its output, and well as the output buffer which it is supposed to truncate. In versions of dompdf prior to 0. This function discards the contents of the topmost output buffer and turns off this output buffering. PHP 8. Basically you just wrap your html in ob_start(); this will return the html as a string so you can echo it. 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. function test_shortcodes () { return 'Shortcodes are working!'; } add_shortcode ('test_shortcodes', 'test_shortcodes'); I have. Gets the current buffer contents and delete current output buffer. (PHP 4 4. Since using a buffer you dont need to save the require to a variable as the html will be returned by ob_get_clean; Share. it uses flush() and ob_flush() functions. Tiện ích lọc dữ liệu: Bạn có thể sử dụng ob_start để lọc. 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. We hope this article has been informative and useful in understanding the ob_start () function in PHP. I prefer to be more explicit with what my code is doing, and I think it is clearer when you split getting the contents of. If you want to further process the buffer's contents you have to call ob_get_contents () before ob_flush () as the buffer contents are discarded after ob_flush () is called. After this is done you are not able to modify header. For example: use function OutputControl\ob_start; use function OutputControl\ob_end_flush; use function OutputControl\ob_get_clean; ob_start (); echo "Hello, world. If i remove line with ob_get_clean () ab_id_transakce have correct variable from form input. Gets the current buffer contents and delete current output buffer. Usually, if you just need to format a string with HTML, just use. ob_flush () is used when you want to flush parts of the page to the client, whereas ob_end_flush () flushes the entire buffer, then destroys the buffer. php on line 946. Hope that is alright. Learn more about Labs ob_get_clean and ob_get_contents return content to screen instead of putting it into variable when used with var_dumpHandling ressources easily. Si fuera necesario continuar procesando el contenido del búfer, se ha de llamar a ob_get_contents () antes que a ob_end_clean (), ya que el contenido del búfer es desechado cuando se llama a ob_end_clean () . 0, PHP 5, PHP 7) ob_get_clean — Get current buffer contents and delete current output buffer Description ob_get_clean ( ) : string Gets the current. 5. Function. Am on a shared server. 1. 1 1 1 silver badge. Asking for help, clarification, or responding to other answers. As a result, the first ob_start () will have an ob_get_level () of 2, the second will be 3, and so on. comes in handy for conditional statements. Tiện ích lọc. . When output buffer is ended it is sent to the client (browser). Hot Network Questions PostGIS fields of type interval not part of QGIS' field list Notepad++ writes a lot to disk after closing Why do many template languages have `for-else` statements?. This function does not destroy the output buffer like ob_end_clean () does. 2. 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(). This means that the output buffer is initiated and stopped with ob_end_clean(). It executes both ob_get_contents () and ob_end_clean () functions. There raises a question, if we use ob_end_clean() to clean the whole output buffer then why even use output buffering. 8) and im getting this error: Fatal error: Cannot instantiate abstract class Renderer in C:xampphtdocs. We next include the template file. My issue now is that the PHP scripts I'm trying to capture output from need variables passed to them using HTTP Get. (The ordering is important: ob_flush() flushes PHP's buffers, flush() then tells Apache to flush it too. Otherwise ob_clean () will not work. If you want to use it for a larger buffer you have to edit your php. So, fortunatly there is some php tools that do interpret the page and can fetch any sub files. El búfer de salida debe estar iniciado por ob_start () con el indicador PHP_OUTPUT_HANDLER_CLEANABLE . ob_end_clean (): bool. This is what I want to prevent. Sorry to resurrect a 4 year old post, but I stumbled across it and wanted to point out that ob_get_contents() followed by ob_clean() is not exactly the same as ob_get_clean(). . 7. Enabling output buffering decreases the download time it takes and renders the HTML in the browser. php some other way. Otherwise I would use them in the shortcode handler, no use to put them in theme. 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. I was trying to debug my code using error_log() and I discovered that ob_get_clean() also truncates the error_log() buffer right in the middle of its output, and well as the output buffer which it is supposed to truncate. function test_shortcodes () { return 'Shortcodes are working!'; } add_shortcode ('test_shortcodes', 'test_shortcodes'); I have. Is there any other way to read file into a variable and parse all the PHP in there. Share. output buffering ob_get_clean not working. 3. Something else is causing that. This function does not destroy the output buffer like ob_end_flush. 5. But in genereal this code is strange, why there is a return? how do you access this code? why is there even. Esta función desecha el contenido del búfer de salida en cola y lo desactiva. ob_get_flush() return the buffer and immediately output it. Answer to your both the question lies in output buffer(ob), Hope this will help you out in understanding. Capture php output of function call. PHP output buffer issue when using ob_gzhandler and ob_clean together. I'm facing a weird problem when using the Elementor Wordpress Page Builder. I'm using PHP 5. 2. 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. Otherwise this function will not work. The output buffer must be. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this siteob_clean (): bool. Code Examples. Có nhiều lợi ích khi sử dụng ob_start trong PHP, bao gồm: Giảm tải server: ob_start có thể giúp giảm tải server bằng cách lưu trữ toàn bộ dữ liệu đầu ra trong bộ đệm (buffer) trước khi gửi nó đến trình duyệt. 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. A callback function can be passed in to do processing on the contents of the buffer before it gets flushed from the buffer. asked Nov 19, 2013 at 0:45. ob_start() starts outbut buffering. But I was able to manage with just these two. I don't see here why you would use them to pass data from PHP to js. If your JavaScript needs something from the server in order to know to redirect or not, do so via an Ajax request. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_CLEANABLE flag. yeah the php script was adding some whitespaces at the beginning and images files became corrupted on downloading, ob_get_clean() fixed it. If not it should be the output-handler you used, check your php. 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. 0, but it seems that the function is deprecated in 4. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. There is a compatibility issue because the Output Buffering has been changed in PHP 8. – r3wt. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order. I think what @toscho tried to say isn't that you can't nest, but that if for some reason you call ob_get_clean() before the code of e. It works. Unfortunately, there is no way to do an implicit ob_flush() after each output, that I am aware of. Just make sure that you call ob_end_flush () the appropriate number of times. corvidmemory corvidmemory. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_CLEANABLE flag. ), 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. Le tampon de sortie doit avoir été démarré avec la fonction ob_start () et le drapeau PHP_OUTPUT_HANDLER_CLEANABLE . Connect and share knowledge within a single location that is structured and easy to search. This will help you better understand. –I am assuming the data displays properly on the site itself and the browser shows your pages are UTF-8. ob_get_clean ( ): string|false. . 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. To troubleshoot this, I would first remove any encoding conversion and try to open the text file in a web browser to eliminate any issues with how you're looking at the file and to confirm it is indeed coming out in UTF-8. x. I'm trying to use the get_the_content() function but instead of pulling the contents of the custom post type I've created it's pulling the contents of the page the shortcode is sitting on. For static files it can check the filesize, but for dynamic files that send output a little by little there is no way to know how many bytes it is going to output. ob_clean() This function removes what is stored in the output buffer. I think I'll better send the output in an HTML file using the code you provided me. 1,658 1 1 gold badge 16 16 silver badges 32 32 bronze badges. Follow edited Oct 8, 2014 at 1:22. Improve this question. Take a look at very simple example for PHP 5. The ob_start () function creates an output buffer. flush is different in that it asks the web server to output PHP's current internal buffer to the client (browser), but to wait for further output (i. If you want to further process the buffer's contents you have to call ob_get_contents () before ob_flush () as the buffer contents are discarded after ob_flush () is called. Understanding ob_start() function in php. Note: The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_CLEANABLE and PHP_OUTPUT_HANDLER_REMOVABLE flags. Return Value: Returns a string containing the contents of the buffer: PHP. ob_get_clean(); Technical Details. ob_end_flush () Deletes the topmost output buffer and outputs its contents. i was using ob_start but it is a banned function for me. In core WooCommerce, the pagination is added via the woocommerce_pagination () function hooked to woocommerce_after_shop_loop, and the sorting and result counts are output by the woocommerce_result_count () and woocommerce_catalog_ordering () functions. Q&A for work. ob_get_clean essentially executes both ob_get_contents and ob_end_clean (). 14. That wasn't the central point of my comment. 43. There are couple of other ob_ functions for more flexibility. Une des plus pratique est ob_get_contents qui permet de récupérer le contenu du tampon de sortie dans une. 2. answered Oct 8. This function will send the contents of the output buffer (if any). GWW GWW. 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. Before you downvote, the reason I added this as an answer and not a comment is I don't have sufficient reputation to comment. Viewed 2k times. Using ob_start() and ob_get_clean() allows you to return HTML code from the shortcode. flush () Attempts to send content from the system's output buffer to the browser. Since `ob_get_clean()` accumulates the entire output in memory, dealing with large amounts of data might affect performance and memory usage. If you say this in PHP: echo 'Hello'; it will result in the string Hello being sent to the browser more or less immediately. 13 of php on MAMP and saw the same problem. 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. For this reason, in previous versions, you were able to echo some content into the HTML. These are the top rated real world PHP examples of ob_GET_clean extracted from open source projects. ob_get_clean() Returns the current buffer contents, then cleans it out. ob_get_clean, only works twice. ob_get_status() returns status information on either the top level output buffer or all active output buffer levels if full_status is set to true. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order. ob_get_clean ( ): string|false. 2k 11 11 gold badges 115 115 silver badges 109 109 bronze badges. Im novice so i dont understand what this doing. In PHP 8. ob_get_length() Get the size of the buffer, in bytes. Follow. thanks! – Alexandru Trandafir Catalin Sep 29, 2014 at 7:45Using the output buffer for this is not a very clean solution. Share. Output Control 함수 목록. You're getting the warning because your script is outputting code before the page headers are sent - meaning you're printing output before the html page. Esta función no destruye el búfer de salida como lo hace ob_end_clean () . 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. ob_get_clean() — Similarly, this will be the combination of ob_get_contents() and ob_end_flush(). If we create. output buffering ob_get. 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 (). Essentially, an output buffer in PHP catches anything that would have been output to the browser (excluding headers). Learn how to use the ob_get_clean () function to get the contents of an output buffer and delete it from the buffer. Sometimes, ob_get_level () may be off by 1 because at the start of the script, it will return 1 even if ob_start () has never been called (and clearing the output buffer via ob_end_clean () and the like can be done without error). 5. 'options' => apply_filters('tutor_monetization_options', array( //add new monetization options here 'free' => __('Disable Monetization', 'tutor'), )),. See answer from @Marc to, ob_get_clean() is the short variant of ob_get_contents(); ob_clean();. Learn how to use the ob_get_clean () function in PHP, an in-built function that cleans or deletes the current output buffer and returns the output buffering again. ob_flush. ob_flush (): bool. If you want to use it for a larger buffer you have to edit your php. First, you can't call a PHP page like that using include_once - the query string will be ignored. This function will send the contents of the output buffer (if any). console. ob_start () use. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. The advantage is when you need to return the entire content of the page (or store it in a variable), rather than just echo it. If you want to use it for a larger buffer you have to edit. The ob_clean () function deletes all of the contents of the topmost output buffer, preventing them from getting sent to the browser. PHP provides a set of functions that control what content is sent to the browser and when. ob_get_clean() combines my use of ob_get_contents() and ob_end_clean(). answered May 17, 2012 at 13:57. ob_end_clean (): bool. But you also need to end and retrieve the contents of the buffer as well. if you don't call ob_start() again with the ob_gzhandler callback function, the output will not be compressed, but the header will say it is. 2 with no alternative. SpaceX's Starship launches on its second test flight from the Starbase facility in Boca Chica, Texas, on Saturday morning. 3. ob_get_clean () is a function that gets the current output buffer contents and deletes it. Definition and Usage. If you want to further process the buffer's. header () cannot be used once any output has begun. Example shortcodes:I found ob_start() and ob_get_clean() in php manual to achieve this. ) The buffer is limited in size, and can easily overrun when left to defaults. WordPress has great filter support for getting at all sorts of specific bits of content and modifying it before output. ob_get_clean (): string|false. The output buffer must be started by ob_start () with PHP_OUTPUT_HANDLER_CLEANABLE and PHP_OUTPUT_HANDLER_REMOVABLE flags. php. htaccess. David Barker David Barker. typo, undefined variable, etc. The string will be captured and echoed. But it looks like the DOMPDF library doesn't work whit big pages. This function does not destroy the output buffer like ob_end_clean() does. Output buffers are stackable, that is, you may call ob_start () while another ob_start () is active. Descripción ¶. Follow answered Feb 29, 2016 at 15:54. –As posts get their data set up via the_post() (respectively via setup_postdata()) and are therefore accessible through the API (get_the_ID() for e. 首先,我們先來看看不讓 echo 之類的內容列印輸出。. WordPress uses get_ for returning almost any function inside the loop without echoing out to the browser. ob_end_clean (): bool. Right now all the stuff that gets included in wp_head are left justified all the way in the code view. Esta función desecha el contenido del búfer de salida. 2. This is fine in contexts where you're outputting stuff directly, but sometimes you want to use that workflow, but capture the output instead of sending it to the browser. However, it is possible that you have output buffering enabled for all files through the output_buffering ini parameter (see the manual ). I wrote these two simple (and hacky) scripts to demonstrate. php: ob_end_flush() stops header() from working. 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ế. . Those 4 lines of code wouldn't display the contents. While this is convenient in some situations for generating documents on-the-fly it also exposes a. I do not want to write different include functions for each include file. Find centralized, trusted content and collaborate around the technologies you use most. This function does not destroy the output buffer like ob_end_flush. . ob_get_clean does two things: it gets the contents of the buffer as a string, and it cleans out the buffer. 6. Trong PHP vốn đã chạy nhanh nay còn có thêm cơ chế cache làm cho ngôn ngữ PHP ngày càng hoàn hảo. Code Examples. If I vardump() the result of the Artisan::call method it just. Follow answered Jul 30, 2014 at 7:16. It seems like MAMP is not performing the function 'ob_get_clean()' correctly. 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. Example #1. corvidmemory. ob_get_clean() silently discards the buffer contents. If i remove line with ob_get_clean () ab_id_transakce have correct variable from form input. ob_clean (): bool. When I run in terminal php artisan migrate this results in 'Nothing to migrate' when indeed there is nothing to migrate. Otherwise ob_get_clean () will not work. Whether the buffer-cleaning functions _should_ invoke the output callback (keeping in mind that in themselves they do not generate. php is just echoed. ob_srtart begins output buffering. ob_get_contents — Return the contents of the output buffer. ob_get_contents — Return the contents of the output buffer. So ob_start() is supposed to capture output until another buffer function is called like ob_get_clean(), ob_get_contents(), ob_get_flush(). The string includes specials tags like the following as well as normal text + images. php - output buffering ob_get_contents not returning anything. Like the_content filter, which lets you access the markup for a post before it's output to the screen. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Collectives™ on Stack Overflow. So the fix I’m suggesting is this:So the original code was without the action? if thats the case you have a ob_get_clean() after a return, return, well, returns the value (in this case a json string) and stops there, no other code after return is being executed. ob_get_contents() fetches whatever is inside the buffer. It really depends on your use case. php, ignoring any *. 0, PHP 5, PHP 7) ob_get_clean — Get current buffer contents and delete current output buffer Description ob_get_clean ( ) : string Gets the current buffer contents and delete current output buffer. The ob_end_flush () function deletes the topmost output buffer and outputs all of its contents. Learn more about CollectivesCollectives™ on Stack Overflow. ob_get_clean returns a string of whatever has entered the output buffer since your ob_start () call and then deletes the contents from the buffer (in this particular example you never set the output of this function to anything, so your code should do nothing). php some other way. Definition and Usage. See the syntax, return value, and examples of this function in PHP. También se usa para obtener el búfer de salida nuevamente después de limpiar el búfer. I assume that is the underlying part of Intervention too, but you can see the issues lies with how to deal with. Thanks Anyway! :) php; while-loop; Share. The PHP ob_get_clean() function returns the contents of the current output buffer and then deletes this output buffer. 4. Note, this section of your code:Capture HTML output. The output may be caught by another output buffer, or, if there are no other output buffers, sent directly to the browser. Share. And for that, you can give him the content like the previous example, or give an url. dompdfincludedompdf. com Learn how to use the ob_get_clean () function to get the contents of an output buffer and delete it from the buffer. The ob_get_length () function returns the length of the topmost output buffer's contents in bytes. Everything works normally but the returned HTML structure is broken. 3. The ob_get_level () function indicates how many output buffers are currently on the stack. Basically you need to ob_start() before first html tag or php code printing the data - if that div stage1sat should belong to message, then you need to move ob_start before it. The output may be caught by another output buffer or, if there are no other output buffers, sent directly to the browser. Be sure your includes do not already send something to the browser. The ob_flush () function outputs the contents of the topmost output buffer and then clears the buffer of the contents. Share. ini involving setting output_buffer and/or zlib. This is also an example of illustrating the ob_start () function of the PHP Programming Language which helps in handling the output buffering. Of course, I was overlooking the fact that the only reason to use the callback on ob_start() was because I wanted to run Obfuscate() on the content before it was flushed, but if I'm getting that content back I don't need to run a callback! So, not using a callback and just running ob_get_clean()'s results through Obfuscate() does what I wanted. So, the functions ob_start(); ob_get_contents(); and ob_end_clean(); don't work. 1. When placing a shortcode on a custom WordPress page the output is always displayed at the top of my page content. ob_flush (): bool. 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. Asking for help, clarification, or responding to other answers. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. If output buffering is turned off, then echo will send data immediately to the Browser. 5. Definition and Usage. There are two other functions you typically pair it with: ob_get_contents (), which basically gives you whatever has been "saved" to the buffer since it was turned on. 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. flush () may not be able to override the buffering scheme of your web server and it has no effect on any client-side buffering in the browser. Asking for help, clarification, or responding to other answers. While returning from the function you have to use ob_start() and ob_get_clean() then alone you can get the result in the place where you need. It just executes the code without any feedback. The W3Schools online code editor allows you to edit code and view the result in your browser1 Answer. So why in manual these functions are under control PHP_OUTPUT_HANDLER_CLEANABLE const? I'm confused about using flags in. See syntax, parameters, return value and examples of this function. Hey, no it didn't work Salut, je suis encore en apprentissage de la programmation web notamment avec PHP ou je suis encore novice . If you want to integrate a new plugin to sell courses and include the selection option in Tutor LMS > Settings > Monetization, then you can use the tutor_monetization_options filter. ob_get_clean — Get current buffer contents and delete current output buffer. This function takes a string as a parameter and should return a string. ob_get_clean does two things: it gets the contents of the buffer as a string, and it cleans out the buffer. 1 Answer Sorted by: 9 This will return the same as your example given : ob_start (); echo 'custom code'; echo 'another line of custom code'; echo 'more code'; return ob_get_clean (); Share Follow answered May 18, 2017 at 10:53 George Dimitriadis 1,691 1 19 27 Add a comment Your Answer The ob_get_contents () function has different return behaivor in PHP 5. Closed. As a PHP developer, you may need to get the contents of the output buffer. 3. This function discards the contents of the topmost output buffer and turns off this output buffering.