note 38537 deleted from language.oop by nlopess

From: Date: Fri, 26 Dec 2003 09:41:02 +0000
Subject: note 38537 deleted from language.oop by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62482@lists.php.net to get a copy of this message
Note Submitter: cyrille2@free.fr ---- Classes and functions' call this exemple will not work: <? class interface { var $maquette; function flushsite ($str) { $tags = array( '[TITLE]', '[COPYRIGHT]', '[BODY]' ); $contents = array( $GLOBALS['title'], $GLOBALS['copyright'], $str ); return str_replace($tags,$contents,$this->maquette); } function interface ($nb='') { // chargement de la maquette $file = $GLOBALS['include_path'].'maquette'.$nb.'.html'; if (file_exists($file)) { $this->maquette = file_get_contents($file); ob_start("flushsite"); //Won't work // won't work with ob_start("$this->flushsite"); return 1; } else return 0; } } ?> The only way I found is to use a function which is not in any class and to use constants (or globals) for the additional arguments... <? function flushsite ($str) { $tags = array( '[TITLE]', '[COPYRIGHT]', '[BODY]' ); $contents = array( $GLOBALS['title'], $GLOBALS['copyright'], $str ); return str_replace($tags,$contents,maquette); } class interface { function interface ($nb='') { // chargement de la maquette $file = $GLOBALS['include_path'].'maquette'.$nb.'.html'; if (file_exists($file)) { define('maquette',file_get_contents($file)); ob_start("flushsite"); return 1; } else return 0; } } ?> Please notice that my global's vars are defined in an included file ;)

« previous php.notes (#62482) next »