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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:47:54+00:00 2026-05-20T22:47:54+00:00

I am new to using classes heavily, and was wondering if going so far

  • 0

I am new to using classes heavily, and was wondering if going so far as to create a class specifically for templates was going to far. Here is a simplified version of my class template. Yes, I know I the use of unset is not necessary, but I like it there so don’t give me any grief for it.

class template{
    private $templateString = "";
    private $templatePlaceholderStrings = array();
    private $templatePlaceholderValueStrings = array();

    function fillTemplateString($string){
        $this->templateString = $string;
        unset($string);
    }

    function fillTemplatePlaceholderStrings($array){
        $this->templatePlaceholderStrings = $array;
        unset($array);
    }

    function filltemplatePlaceholderValueStrings($array){
        $this->templatePlaceholderValueStrings = $arrray;
        unset($array);
    }

    function buildTemplate(){
        return preg_replace($this->templatePlaceholderStrings,
                    $this->templatePlaceholderValueStrings,
                    $this->templateString);
    }
}
  • 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-20T22:47:55+00:00Added an answer on May 20, 2026 at 10:47 pm

    Here’s the rule of thumb I’d suggest to anyone who is unsure about how much OOP they should use: use classes and objects wherever they make your life easier.

    In your case, I guess it will allow you to incrementally add variables/placeholders to your templates and it will centralize template handling so that you don’t have to go around and search/replace code all over your files whenever you’ll want to change things, so I guess it’s a pretty good idea.

    Edit: I misread your class originally, you should probably have something like this, if you want to be able to add placeholders from different part of your script rather than in one big call

    function addPlaceholder($placeholder, $value){
        $this->templatePlaceholderStrings[] = $placeholder;
        $this->templatePlaceholderValueStrings[] = $value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using generic classes. Here is my question: I have several enumerations
I used to create instances of my JavaScript classes using the new keyword and
Whenever I create new classes using Visual Studio 2010 Express C# it creates them
I'm using new style classes in Python 2.6 and am having trouble with __getattr__
I've seen this quite a few times while using Office Interop classes this.CustomXMLParts.Add(MyResources.Data, new
Using the .NET System.ServiceModel.Syndication classes... I would like to add a new SyndicationElementExtension to
I made some classes using xjc. public class MyType { @XmlElementRefs({ @XmlElementRef(name = MyInnerType,
Sorry if this is wrong or confusing I am very new to using classes
I'm new to using inherited classes, so I may be missing something completly obvious.
I am pretty new to using object/classes in PHP and I am curious about

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.