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 8802715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:09:23+00:00 2026-06-14T01:09:23+00:00

I hope somebody can help me, i am oop starter and the script below

  • 0

I hope somebody can help me, i am oop starter and the script below gives output < but i want this <input type="text">.

Now i created a Build class but it doesnt work. What do i do wrong and how can i fix this?
Can somebody help me?
Thnks!

//set get Element
class Element {
    private $_element; 

    function addElement($element) {
        $this->_element = $element;
    }

    function getElement(){
        return $this->_element;
    }
}
//add and set Atrr
class attrType extends Element {
    //set var 
    public $_attrType;

    function __construct(){     
        $this->_attrType = array(); 
    }

    function addAttr($attrType, $attrValue){
        $this->_attrType[$attrType] = $attrValue;
    }

    function getAttr(){
        return $this->_attrType;
    }
}
//build input text field
class Build extends attrType {
    function Builder() {
        $html .= "<";
        $html .= ''.$this->getElement();

        foreach( $this->getAttr() as $key => $value){       
            $html .= " $key=";
            $html .= "\"$value\">";
        }

        return $html;
    }    
}

$element = new Element();
$attr = new attrType();
$build = new Build();

$attr->addElement('input');
$attr->addAttr('type','text');
echo $build->Builder();
  • 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-06-14T01:09:24+00:00Added an answer on June 14, 2026 at 1:09 am

    Change your code as shown below

    $build->addElement('input');
    $build->addAttr('type','text');
    

    instead of

    $attr->addElement('input');
    $attr->addAttr('type','text');
    

    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a total dah question but I hope somebody can help me out.
I hope somebody can help me with this. I have a script that generates
Hope somebody can help. Have looked around on the net but cannot seem to
i have a problem with jquery/visible. Hope somebody can help me. This code works,
I have spent hours on this problem, I hope somebody can help me. Sorry
I am not very good with this, so I hope somebody can help me.
I hope somebody can help work out to do this. Basically, I have a
Hope somebody can help me out of this confussion. I made this method: public
I'm currently stuck with this problem and I hope somebody can help me out.
I have a small problem, but I hope somebody can help. Let's say that

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.