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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:50:22+00:00 2026-06-16T06:50:22+00:00

Anyone know how to redeclare function? For example: class Name{} //Code here class Name{}

  • 0

Anyone know how to redeclare function?
For example:

class Name{}
//Code here
class Name{}

And the output is:
Cannot redeclare class

So I tried to name the class as a variable:

$foo = 'name';
class $foo{}

//Code

class $foo{}

Edit: I have a DataBase table and I am reading data from the table user ‘while()’ loop.

I have a class that uses the table and echo some information.
That is the reason.

And it’s still not working…
Any suggestions?

  • 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-16T06:50:23+00:00Added an answer on June 16, 2026 at 6:50 am

    Use PHP NameSpace

    namespace A {
    
        class Name {
    
            function __toString() {
                return __METHOD__;
            }
        }
    }
    
    namespace B {
    
        class Name {
            function __toString() {
                return __METHOD__;
            }
        }
    }
    
    namespace C {
    
        echo new \A\Name ,PHP_EOL;
        echo new \B\Name ,PHP_EOL;
    }
    

    Output

    A\Name::__toString
    B\Name::__toString
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know what can cause this problem? PHP Fatal error: Cannot redeclare class
Anyone know an example of phonegap with $.ajax() in github for Android? I have
Anyone know if the C2DM source code is open? If so, where is it
Anyone know why the following unit test does not pass? describe(just a test, function
Anyone know how facebook did this: From what I know we cannot change the
Anyone know if it's possible to access the name of a jump link in
After I do: zf -p create dbtable.from-database I get: Cannot redeclare class Zend_Loader in
Anyone know how to count updates post per day (example: in this day/date) in
anyone know the custom css selector for dijit.MenuItem label? here's the js that adds
Anyone know how to turn off code folding in visual studio 2008? Some of

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.