Hooks not working iff im using @ob_start() |
Hooks to minimize and compress html code is working fine, if i am not using @ob_start(), but i need to use this function to remove several problems like ** "PHP: Cannot modify header information", die() and exit() not working...** . Using @ob_start() makes useless to minify and compress function.
Could you provide us with an example code?
Why are you bothering with compressing HTML? With modern internet you will not find it worth your while, as long as you have gzip enabled on your server for HTML. Have you placed exit; after all your redirect(); functions? That's the only way to get rid of "Cannot modify header information"*. If it's not your redirect() functions creating problems, you may have whitespace in your files. UTF-8 BOM etc in your files. https://stackoverflow.com/a/8028987 * The easy way at least, as you need to stop it rendering HTML or other content that sends headers.
(01-05-2020, 06:28 AM)shailesh tripathi Wrote: Hooks to minimize and compress html code is working fine, if i am not using @ob_start(), but i need to use this function to remove several problems like ** "PHP: Cannot modify header information", die() and exit() not working...** . Using @ob_start() makes useless to minify and compress function. I am using following code using Hooks file- PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); PHP Code: <?php
(01-05-2020, 11:30 PM)jreklund Wrote: Could you provide us with an example code?Im using that code to remove comments and whitespaces & other stuff to reduce html rendered page code upto few lines. Code is working fine without any problem. Using ob_start() function makes is uneffective. I have updated the question by providing sample code .
IF you look at your code you are loading the title twice and also jQuery twice.
I suggest that you go to w3schools and catch up on html. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Well it's a proven fact that any kind of errors can cause multiple other errors.
So you start by fixing your current errors that you know about then proceed with the other errors. And your ob_start should be place above the class under the <php What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
It may be that you never flush it as CodeIgniter already buffers it's output. So you are getting double buffering.
https://github.com/bcit-ci/CodeIgniter/b...r.php#L947 But my recommendation are that you ignore this minify and enable gzip compression instead. https://github.com/bcit-ci/CodeIgniter/b...g.php#L420 If you aren't doing it on server level. (This is the recommended way!) If you still want it to work, with that slow preg_replace function. You need to fix your redirect(); and add a working exit; as they do work. If applied correctly. Do you have an example that dosen't work? You aren't using a caching server I guess? That mean you will be running that replace every time a user visit that page.
(01-08-2020, 11:56 AM)jreklund Wrote: It may be that you never flush it as CodeIgniter already buffers it's output. So you are getting double buffering.You are right as because Buffering by Codeigniter is probably the reason behind it. Thanks for this suggestion, I should use gzip compression. "That mean you will be running that replace every time a user visit that page." ---> Yes "Do you have an example that doesn't work?" ---> I will share the code where i am getting the problem on exit() and die() when im not using ob_start() as soon as possible.
(01-07-2020, 09:21 AM)InsiteFX Wrote: Well it's a proven fact that any kind of errors can cause multiple other errors.Thanks, i have done that correction in code that you had suggested previously . I have changed the position of the ob_start to Under php tag, but still facing that problem. |
Welcome Guest, Not a member yet? Register Sign In |