You can not call a PHP function in a JavaScript file in this way. You can do it by following these steps:
1) create get-users.php file
<?php
require 'functions.php';
echo getUsers();
?>
2) make the http request to the created file
$scope.users = $http({
method: 'GET',
url: 'your-website-url/get-users.php'
}).then(function(response){
$scope.users = response.data;
},function(reason){
$scope.error = reason.data;
});
}
Update
if you have a lot of functions and don't want to create a file for every function. then you can do it like this:
1) create all-functions.php file
<?php
require 'functions.php';
if (function_exists($_GET['func'])) {
echo call_user_func($_GET['func']);
} else {
echo "Error: function does not exist";
}
?>
2) Update your angular code
$scope.users = $http({
method: 'GET',
url: 'your-website-url/all-functions.php',
data: {
func: 'getusers'
}
}).then(function(response){
$scope.users = response.data;
},function(reason){
$scope.error = reason.data;
});
}