I have a Response.php file which has a function inside and i want to call the function to another .php file.
here's the Response.php
<?php
include 'connection.php';
$response = array();
class Response_Function{
public function fieldMissing() {
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
$response = json_encode($response);
echo $response;
}
}
?>
and this is the file calling the fieldMissing() function
<?php
include 'connection';
require_once 'include/Response.php';
$db = new Response_Function();
$response = $db->fieldMissing();
echo $response;
?>
return $response;instead ofecho $response;, because as it is the function doesn't return anything. Therefore, in the second file $response will have no useful value assigned to it.