-3

I have two files (Ex-one.php,two.php). Some functions have same name in two files. A have another class file. I include that file(one.php,two.php) in two functions on class file. Then I create a object from class file in main php file. Then i call two functions in object(call functions in class file). when I call the function second time error occur ("Cannot function_name() (previously declared in **Previase include file name **")

how I Solve this issue

one.php

function a(){
   }
   function d(){}

two.php

    function a(){
  }
  function d(){}

class file -----------

   class test{

 function one(){
  include_once("one.php")
 }

 function two(){
   include_once("two.php")
 }

}

main file ---------

    $test=new test();
$test->one();

$test->two();//(**in this line error occur**)

1 Answers1

0
    namespace xxx {
         function A {}
    }
    namespace yyy{
         function A{}
    }

Not in the same file ofcourse. then to call them include and use \xxx\A

Php.net: Namespaces

Combinu
  • 882
  • 2
  • 10
  • 31