Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 743737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:53:53+00:00 2026-05-14T08:53:53+00:00

I’ve defined an abstract superclass in one file and a subclass in another. I

  • 0

I’ve defined an abstract superclass in one file and a subclass in another. I have required the super-classes file and the stack trace reports to find an include it.

However, it then returns an error when it hits the ‘extends’ line: Fatal error: Class 'HTMLBuilder' not found in View/Markup/HTML/HTML4.01/HTML4_01Builder.php on line 7.

I had this working with another class tree that uses factories a moment ago. I just added the builder layer in between the factories and the consumer. The factory layer looked almost exactly the same in terms of includes and dependencies.

So that makes me think I must have done something silly that’s causes the HTMLBuilder.php file to not be included correctly or interpreted correctly or some such.

Here’s the full stack trace (paths slightly altered):

#   Time    Memory  Function    Location
1   0.0001  53904   {main}( )   ../index.php:0
2   0.0002  67600   require_once( 'View/Page.php' ) ../index.php:3
3   0.0003  75444   require_once( 'View/Sections/SectionFactory.php' )  ../Page.php:4
4   0.0003  81152   require_once( 'View/Sections/HTML/HTMLSectionFactory.php' ) ../SectionFactory.php:3
5   0.0004  92108   require_once( 'View/Sections/HTML/HTMLTitlebarSection.php' )    ../HTMLSectionFactory.php:5
6   0.0005  99716   require_once( 'View/Markup/HTML/HTMLBuilder.php' )  ../HTMLTitlebarSection.php:3
7   0.0005  103580  require_once( 'View/Markup/MarkupBuilder.php' ) ../HTMLBuilder.php:3
8   0.0006  124120  require_once( 'View/Markup/HTML/HTML4.01/HTML4_01Builder.php' ) ../MarkupBuilder.php:3

Here’s the code in question:

Parent class (View/Markup/HTML/HTMLBuilder.php):

<?php

require_once('View/Markup/MarkupBuilder.php');

abstract class HTMLBuilder extends MarkupBuilder {

    public abstract function getLink($text, $href);

    public abstract function getImage($src, $alt);

    public abstract function getDivision($id, array $classes=NULL, array $children=NULL);

    public abstract function getParagraph($text, array $classes=NULL, $id=NULL);

}

?>

Child Class, (View/Markup/HTML/HTML4.01/HTML4_01Builder.php):

<?php

require_once('HTML4_01Factory.php');
require_once('View/Markup/HTML/HTMLBuilder.php');


class HTML4_01Builder extends HTMLBuilder {
    private $factory;

    public function __construct() {
        $this->factory = new HTML4_01Factory(); 
    }

    public function getLink($href, $text) {
        $link = $this->factory->getA();
        $link->addAttribute('href', $href);
        $link->addChild($this->factory->getText($text));
        return $link;   
    }

    public function getImage($src, $alt) {
        $image = $this->factory->getImg();
        $image->addAttribute('src', $src);
        $image->addAttribute('alt', $alt);
        return $image;
    }

    public function getDivision($id, array $classes=NULL, array $children=NULL) {
        $div = $this->factory->getDiv();
        $div->setID($id);
        if(!empty($classes)) {
            $div->addClasses($classes);
        }   
        if(!empty($children)) {
            $div->addChildren($children);   
        }
        return $div;
    }

    public function getParagraph($text, array $classes=NULL, $id=NULL) {
        $p = $this->factory->getP();
        $p->addChild($this->factory->getText($text));
        if(!empty($classes)) {
            $p->addClasses($classes);   
        }
        if(!empty($id)) {
            $p->setID($id); 
        }
        return $p;
    }

}


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:53:53+00:00Added an answer on May 14, 2026 at 8:53 am

    Note that, in the trace, HTMLBuilder.php requires MarkupBuilder.php requires HTML4_01Builder.php. You’ve got an include cycle. When HTML4_01Builder is defined, PHP hasn’t finished processing HTMLBuilder.php. In particular, it hasn’t reached the beginning of the abstract class HTMLBuilder definition.

    There’s no need to include a descendent class when defining the ancestor. PHP uses late binding of class names, so the descendent only needs to exist by the time the methods are invoked.

    MarkupBuilder.php:

    <?php
    // unnecessary: 
    //require_once('View/Markup/HTML/HTML4.01/HTML4_01Builder.php');
    
    class MarkupBuilder {
        static public function getInstance(...) {
            ...
            return new HTML4_01Builder(...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.