php - Why Code igniter holds the output of views in a buffer -
i have basic code below new code igniter pardon if question sound amateur
public function view($num = 0) { echo "view called<br>"; $this->load->view("header"); $this->load->view('xyz'); $this->load->view('footer'); echo "view function ended"; }
ok want know why code igniter doesn't output result way homecoming
the ouptut of code following
view called output of result calling random_func() renders viewwhat expected output next
view called renders view output of result calling random_func()is there code igniter specific behavior missing on?why code igniter holding views in buffer ?
if follow codeigniters lifecycle in /system/core/codeigniter.php
see final output gets called near end of file.
so views output browser last, regardless of how called.
when view called, gets stored in buffer can manipulated before gets sent final render.
manipulating buffer storing 1 view in another, parsing/injecting variable data/tags etc.
codeingiter lifecycle(in order) defines global constants(ci_version, ci_core) version control loads core/common.php file includes global helper functions checks environment framework running under(local/remote) sets custom error handler handling errors/exceptions loads config file check if there custom subclass prefix eg: (my_) set liberal script execution time limit loads benchmark class under line can benchmarked! loads hook class , checks if 'pre_system' hooks defined in application/hooks loads main config file , assigns within file config array loads utf-8 , uri classes loads router class , sets default route in /application/config/routes.php => default_controller loads output class , checks if there in cache can output straightaway loads security/input/lang classes loads controller class(entry point) , sub classes extend in application/controllers checks see if controller method begins , _ => private does other security checks , looks index method in controller , searches requested controller looks pre_controller hook instantiates requested controller step 16 looks post_controller_construct hook looks controller _remap override function looks post_controller hook, happens after controller __construct method has been called outputs final render(buffer) browser looks post_system hook closes db connections open back step 1as can see cycle, if wanted intercept @ point, created hook, , hooks injected @ point hooks called.
hope helps
php codeigniter output-buffering
No comments:
Post a Comment