Php calling a function in one class out of another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
evolvedlight
Forum Newbie
Posts: 2
Joined: Mon May 29, 2006 11:02 am

Php calling a function in one class out of another

Post by evolvedlight »

Ok, I'm using a login system from evolt.org - its at http://evolt.org/PHP-Login-System-with-Admin-Features

Now, I have a class called Page which does various stuff including checking if they are logged in by:

Code: Select all

if($session->logged_in)
{
show logout button
}else {
show login form
}
now, I can't seem to reference this $session class from within my page class:

I can have the following on my Index Page and it will work fine

Code: Select all

if($session->logged_in)
		{
			$indexPage->WriteLoggedIn();
		} else {
			$indexPage->WriteLoginForm();
		}
However, if I have the following code within the function Make() that creates the page, it will NOT work.

Code: Select all

if($session->logged_in)
		{
			$this->WriteLoggedIn();
		} else {
			$this->WriteLoginForm();
		}

How do I get this working please?

S
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

The problem looks like it is in the organization of your code and nothing to do with the Evolt code. You would need to show us some more code. It is not clear in what context that if() statement is being run. As $this references the current object from within its methods we would need to see that code.
(#10850)
Post Reply