note 38537 added to language.oop
| From: | cyrille2 at free dot fr | Date: | Fri, 26 Dec 2003 06:11:20 +0000 |
| Subject: | note 38537 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62473@lists.php.net to get a copy of this message | ||
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 ;)
----
Manual Page -- http://www.php.net/manual/en/language.oop.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38537
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38537&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38537&report=yes
Search -- http://master.php.net/manage/user-notes.php