note 33857 deleted from function.ob-start by sniper

From: Date: Mon, 03 Nov 2003 15:36:16 +0000
Subject: note 33857 deleted from function.ob-start by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59689@lists.php.net to get a copy of this message
Note Submitter: karlos@kastaneda.kiev.ua ---- Using objects and output buffering, again... In deed, you can ob_start() right from object's constructor. Details: when (in PHP4) you execute something like $object = new ClassName; the object is 1) created, 2) copied to $object variable. Of couse, using =& may help you to avoid 2). Try this (it works, at least, at my PHP 4.3.2): <?php class myPage { var $header; function myPage() { ob_start(array(&$this,"output")); } function output($raw_data) { return "<h1>{$this->header}</h1>$raw_data"; } } $_page=&new myPage(); // note "=& new" ;-) $_page->header="Some Header"; ?> ...page contents P.S. AFAIK in PHP5 this behavior will be changed. Any comments? P.S.#2 Sorry for my worse English.

« previous php.notes (#59689) next »