Posted by Wescotte on 04/14/06 19:49
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.
Now I currently have a functions setup that just reads a file and
determines which file type it is and includes the correct source. My
goal is add a new function to each source called
My_File_Format($filename) where each file checks to see if the
specified file is the format it knows how to work with.
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
Assumed should be
Test1Test2
file testcase.php
<html>
<body>
<?php
class file_format
{
var $f;
function file_format($filename)
{
$this->f = $filename;
}
function is_format()
{
include "$this->f";
test_case();
}
}
$a = new file_format("test1.php");
$b = new file_format("test2.php");
$a->is_format();
$b->is_format();
return;
?>
</body>
</html>
file: test1.php
<?php
function test_case()
{
echo "Test1";
}
?>
file: test2.php
<?php
function test_case()
{
echo "Test2";
}
?>
[Back to original message]
|