Reply to Re: Problems with include and duplication function definitions

Your name:

Reply:


Posted by Colin McKinnon on 04/14/06 20:15

Wescotte wrote:

> I have an application that uses several file formats for similar data.
> So I've created various php files for each format containing the same
> functions which produce the same end result.
>
<snip>

>
> The problem I'm running into is duplicate function names. Here is a
> test case of what exactly I was attempting to do. Anyone know how to
> actually get this to work?
>
> Output:
> Test1
> Fatal error: Cannot redeclare test_case() (previously declared in
> C:\Inetpub\Accounting\test1.php:5) in C:\Inetpub\Accounting\test2.php
> on line 6

Sorry Wescotte - while many people bemoan the lack of namespaces in PHP,
really this is just sloppy programming. If you are applying a procedural
methodology then you should be planning your program better - while you
might have deliberately chosen the same naming strategy for different the
functions in different include files - there's something wrong if it's
including more than one. In fairness, this is a very common mistake, and
one of the reasons for object oriented programming (which obviates such
eventualities).

So I guess the solutions are:
1) look at your flow of control - only include one file
2) or learn OO.

C.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация