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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:31:08+00:00 2026-06-02T06:31:08+00:00

I know there is tidy php class by default already, what about if I

  • 0

I know there is tidy php class by default already, what about if I want to create my own custom tidy class and I want to name that class as tidy too?

class tidy
{
    public function html()
    {
        return 'local';
    }
}

$tidy = new tidy();
echo $tidy->html();

error,

Fatal error: Cannot redeclare class tidy in
C:\wamp\www\test\2012\php\dom_tidy_html_8.php on line 11

How can I not to conflict with PHP’s default tidy?

Is it possible?

EDIT:

I tested it with namespace and it works but I am not whether this is a good practice or not…? I haven’t done anything with namespace before so I am not sure whether it is safe or not…

namespace tidy;

class tidy
{
    public function html()
    {
        return 'local';
    }
}

$tidy = new tidy();
echo $tidy->html();

Would it cause any problem if I want to use the PHP default tidy occasionally?

  • 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-02T06:31:10+00:00Added an answer on June 2, 2026 at 6:31 am

    If you want to build on top of tidy then just extend the tidy class and call is myTidy.

    class myTidy extends tidy
    {
        public function html()
        {
            return 'local';
        }
    }
    
    $tidy = new myTidy();
    echo $tidy->html();
    

    If you want to create your own implementation from scratch try to remove the tidy module and then create the tidy class.

    If you are using PHP >= 5.3.0 you can also create your own tidy class in a Namespace :

    namespace My\Tidy;
    
    class tidy
    {
        public function html()
        {
            return 'local';
        }
    }
    
    $tidy = new tidy();
    echo $tidy->html();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is a lot of talk about BPM these days and I
I know there is a method like this : setTimeout(functionA();,1250); That can delay my
I know there are hundreds of questions about UTF-8 woes but I tried all
I know there are billions of threads about SQL Databases, but I didn't find
I know there are many threads about calculating from lat/long to metric systems. This
I know there is a lot of controversy (maybe not controversy, but arguments at
I know there has to be a way: I need help getting any hot
I know there is ongoing work for in this regards but what is the
I know there is a very similar question here but I was hoping to
I know there are implementations of Python and of Perl for .NET. Have you

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.