Strange behaviour
| From: | Ovidiu EFTIMIE | Date: | Wed, 20 Sep 2000 15:31:43 +0000 |
| Subject: | Strange behaviour | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-17223@lists.php.net to get a copy of this message | ||
Hi everybody,
I've noticed a strange behavior when workig with classes.
For example:
I have page,I shall call it H where I'm using an error object called,
obviously, error.
This object is not included directly but with another object called
connexion,which extends the error object
So in the H page I have require_once("connexion.php"); which will include
both connexion.php and error.php.
The error object has a configuration file called error.conf.php,included
with require_once(), where I define error messages like :
define("NOT_AUTHORIZD","Sorry you are not authorized to
view this page, bla,bla,bla");
In H page I call the error object like this:
$errPage=new error();
$errPage->showError(NOT_AUTHORIZED);
I'am also using the template class developped by Richard Hayes with few
improvements.
So the showError() function will receive a parameter which is constant and
normaly it should look like this
function showToUser($err){
$tpl=new template;
$tpl->load_file('error','../templates/error.html');
$tpl->register('error',"err");
$tpl->parse('error');
$tpl->print_file('error');
}
The problem is that the function it does'n display the message unless I
declare a global variable and assign the constant value to it.
The showError() function looks like this:
function showToUser($err){
global $errorcode;
$error_const=$err;
$tpl=new template;
$tpl->load_file('error','../templates/error.html');
$tpl->register('error',"error_const");
$tpl->parse('error');
$tpl->print_file('error');
}
Anyone has any ideea?