Jump to content


OOP - child attributes

  • Please log in to reply
No replies to this topic

#1 ToonMariner

  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 April 2006 - 02:20 PM

another oop prob!!!!

I want to use an attribute created in a child class in its parent - not having much luck.

The impudent child!!!

class login_check extends page {

 public function draw_loginform()
  $username    =    isset($_POST['username'])    ?    $_POST['username'] : NULL;
  $this->loginhtml = <<<HTMLSTART
<div id="loginform">
 <form action="cmslobby.php" name="loginfrm" id="loginfrm" method="post" enctype="application/x-www-form-urlencoded" target="_self" lang="en" dir="ltr">
  <label lang="en" dir="ltr" for="username">Username:</label> <input name="username" type="text" id="username" tabindex="1" title="UserName" dir="ltr" lang="en" size="10" maxlength="20" value="$username"><br />
  <label lang="en" dir="ltr" for="password">Password:</label> <input name="password" type="password" id="password" tabindex="2" title="Password" dir="ltr" lang="en" size="10" maxlength="20"><br />
  <input type="hidden" name="refurl" id="refurl" value="$this->self">
  <input name="login" type="submit" id="login" tabindex="3" title="Login" dir="ltr" lang="en" value="Login"><br />
<div class="clear"></div>


The disspaing parent...

class page {

 public function pagehead_Section ()
  echo <<<HTMLSTART
<div id="header">
 <h1><a href="/admin/cmslobby.php" target="_self" title="Foundry CMS Home"><span>Foundry CMS</span></a></h1>

  echo login_check::$loginhtml;
  echo <<<HTMLSTART



Other properties exist in there of course but these are the bits I can't get to work.

The error returned is:

Fatal error: Access to undeclared static property: login_check::$loginhtml in C:\Program Files\Apache Group\Apache2\htdocs\nas\admin\includes\class\page.inc.php on line 99

For those incredibly sharp people teh $this->self is set in the parent constructor function and is $_SERVER['PHP_SELF'] - but that has no bearing on the error returned...

Any help much appreciated.
follow me on twitter @PHPsycho

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users