Strange Cannot redeclare class fatal error...

Discussion in 'PHP' started by benjib98, Jan 10, 2008.

  1. #1
    I am using Zend Development Environment for writing and debugging php code.But when trying to run my code I receive a fatal error:
    Fatal error: Cannot redeclare class SOAPParam in C:\...\SOAP.php on line 101

    The weird thing is , that the class SOAPParam exists only once, so surely there is no other declaration in the code, but when I am writing the SOAPParam class name in the code, another SoapParam class is coming up in the list together with SOAPParam. But the SoapParam does not have location, source information- the description says only that it is a class...But when I am tried to create an object of type SoapParam, it behaves as it is of SOAPParam type.
    Can anyone suggest what could go wrong???
    PS: tried to search for SoapParam (matching case) in the files I am using in the project, but nothing. Also searched the zend project file for any lead to it but nothing at all.
    Cheers
     
    benjib98, Jan 10, 2008 IP
  2. benjib98

    benjib98 Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    sorted out the problem listed above:
    I wrote my own class SOAPParam(), which implementation is different from the built in PHP SoapParam(), so obviously PHP has treated them as the same class and failed with an error.
    Cheers
     
    benjib98, Jan 10, 2008 IP
  3. ausome

    ausome Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey Benjib98,

    Just a question,

    If your new Class is very different to the existing one, why not rename it.

    Also if it's not too different you could extend the existing class.

    It's not really safe to use an existing name of a already defined Class.

    It's like Turning a Car into a Train and calling it a Car!
    Although an exisitng Car could be extended to be a Train or the other way around.
    Not quite a good analogy - Its late here!

    Cheers
    Tim
     
    ausome, Jan 11, 2008 IP