tags:

views:

46

answers:

3

hello i want to know how to call a function defined in one php file from some other function defined in some other php page.

+1  A: 

Use include(), require(), etc. on the other PHP file, then just put the function name followed by its arguments in parentheses.

Ignacio Vazquez-Abrams
+2  A: 

First you need to include that file either using

require_once or require

or

include_once or  include

if the function is not in class, you will call directly.

require("file.php");
echo getUserName("1")

otherwise you have to first create object and than call method

require("file.php");
$obj = new User();
echo $obj->getUserName("1");
Adeel
+1  A: 

do like this,
in the file where you need to call the function


require ("file_having_function_that_you_need_to_call.php");

function_name($arguments) // this function is defined in 'file_having_function_that_you_need_to_call.php' file

Gaurav Sharma