1

Topic: Integrating with classes

I am trying to integrate the login system, but the $pun_user array is always empty when I try to access it from a class. Do you know what I can do?

Thanks


The code below prints out only "hello world".
<?
define('PUN_ROOT', './forum/');
require PUN_ROOT.'include/common.php';
//Makes normal pages work if forum is en maintenance mode
define('PUN_TURN_OFF_MAINT', 1);
class test{
function __construct() {
    echo pun_htmlspecialchars($pun_user['username']);
    print_r($pun_user);
    echo "hello world";   
    }
}
?>

2 (edited by Tobi 2005-11-17 19:15)

Re: Integrating with classes

Because $pun_user is not available inside a function, you have to declare it global first.

Or add it to the function:

class test{
function __construct($pun_user) {
    echo pun_htmlspecialchars($pun_user['username']);
    print_r($pun_user);
    echo "hello world";   
    }
}

$tester = new test($pun_user);

Something like this.

The German PunBB Site:
PunBB-forum.de

3

Re: Integrating with classes

Thanks alot. Works fine!