Jump to content

Recommended Posts

another oop prob!!!!

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

The impudent child!!!

[code]
<?php
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 />
</form>
</div>
<div class="clear"></div>
        
HTMLSTART;

}
?>[/code]

The disspaing parent...

[code]<?php
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>

HTMLSTART;
  echo login_check::$loginhtml;
  echo <<<HTMLSTART
</div>

HTMLSTART;
}

}
?>[/code]




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.
Link to comment
https://forums.phpfreaks.com/topic/7723-oop-child-attributes/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.