calling class functions
Posted: Fri Jun 17, 2005 4:02 pm
I'm having problems calling class functions.
"Fatal error: Call to undefined function: showusername() in /home/cts/public_html/phptest/index.php on line 15"
Whenever I try to call the class' functions.
Thanks for any help in advance!
I have a simple class in (CAdminUser.php)
///////////////////////////////////////////// CLASS CODE
//////////////////////////////////////////////////////////////
//////////////// END OF CLASS CODE
///////////////////////////////// INDEX.PHP
////////////////////////////////////////////////////
//////////// END INDEX.PHP
d11wtq | Please use
"Fatal error: Call to undefined function: showusername() in /home/cts/public_html/phptest/index.php on line 15"
Whenever I try to call the class' functions.
Thanks for any help in advance!
I have a simple class in (CAdminUser.php)
///////////////////////////////////////////// CLASS CODE
//////////////////////////////////////////////////////////////
Code: Select all
<?php
session_start();
class CAdminUser
{
var $m_id;
var $m_username;
var $m_password;
function showUsername()
{
echo $this->m_username;
}
function Combine($num1, $num2)
{
return $this->num1 . $this->num2;
}
}
?>///////////////////////////////// INDEX.PHP
////////////////////////////////////////////////////
Code: Select all
<?php
session_start();
require_once('CAdminUser.php');
if(!$_SESSION['CAdminUserData'])
{
$adminUser = new CAdminUser;
$adminuser->id = 0;
$adminuser->username = 'unknown';
$adminuser->password = 'not set';
$adminuser->showUsername(); <====== ERROR HERE
$adminuser->Combine('hello', 'two'); <===== ERROR HERE
$_SESSION['CAdminUserData'] = $adminuser;
// TODO: send user to login page
}
else
{
$theadminuser = $_SESSION['CAdminUserData'];
echo $theadminuser->id . "<BR>";
echo $theadminuser->username . "<BR>";
echo $theadminuser->password . "<BR>";
}
?>d11wtq | Please use
Code: Select all
tags when posting PHP code[/color]