在第 78 行出现 php 致命错误函数名称必须是 C:\wamp\www\drupal-7.42\sites\all\modules\form_fun\form_fun.cake.inc 中的字符串
having php fatal error Function name must be a string in C:\wamp\www\drupal-7.42\sites\all\modules\form_fun\form_fun.cake.inc on line 78
我正在尝试使用 drupal.But 向 moodle 发送一个 curl 请求,每个时间我 运行 这个代码我收到一条错误消息,函数名称必须是 string.I 已经尝试了一切但什么都没有 working.Can 有人帮帮我吗?
function form_fun_cake_submit(&$form, &$form_state) {
$serverUrl=' http://localhost/moodle/my/webservice/rest/server.php?wstoken=d90b5d90db13711d12df525366f15db1';
$functionName = 'core_user_create_users';
$user1 = new stdClass();
$user1->username = 'testusername1';
$user1->password = 'Uk3@0d5w';
$user1->firstname = 'testfirstname1';
$user1->lastname = 'testlastname1';
$user1->email = 'testemail1@moodle.com';
$user1->auth = 'manual';
$user1->idnumber = '';
$user1->lang = 'en';
$user1->timezone = 'Australia/Sydney';
$user1->mailformat = 0;
$user1->description = '';
$user1->city = '';
$user1->country = 'AU'; //list of abrevations is in yourmoodle/lang/en/countries
$preferencename1 = 'auth_forcepasswordchange';
$user1->preferences = array(
array('type' => $preferencename1, 'value' => 'true')
);
$users = array($user1);
$params = array('users' => $users);
/// REST CALL
$rest_format = 'json';
//$server_url = $domain_name . '/webservice/rest/server.php' . '?wstoken=' . $token . '&wsfunction=' . $function_name;
$server_url = 'localhost/moodle/my' . '/webservice/rest/server.php'. '?wstoken=' . '15bd45a3dab2958b7e8fc237b14f76cd' .'&wsfunction='. $functionName;
dpm($server_url);
require_once('curl.inc');
$curl = new curl;
$rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : '';
$resp =$curl($server_url . $rest_format, $params); //This is my line no 78
dpm($rest_format);
$respRc = json_decode($resp, true);
dpm($resp);
echo '</br>************************** Server Response createUser()**************************</br></br>';
echo $server_url . '</br></br>';
var_dump($resp);
}
第 78 行将 $curl(...) 替换为 new curl(..),您的对象实例化不正确。告诉 php 日志的是,您正在使用一个变量作为函数名称,又名 $curl(与 $functionName 无关,如果错误,稍后可能会生成错误,而 curl 不会编译)。
$resp = new curl($server_url . $rest_format, $params);
我正在尝试使用 drupal.But 向 moodle 发送一个 curl 请求,每个时间我 运行 这个代码我收到一条错误消息,函数名称必须是 string.I 已经尝试了一切但什么都没有 working.Can 有人帮帮我吗?
function form_fun_cake_submit(&$form, &$form_state) {
$serverUrl=' http://localhost/moodle/my/webservice/rest/server.php?wstoken=d90b5d90db13711d12df525366f15db1';
$functionName = 'core_user_create_users';
$user1 = new stdClass();
$user1->username = 'testusername1';
$user1->password = 'Uk3@0d5w';
$user1->firstname = 'testfirstname1';
$user1->lastname = 'testlastname1';
$user1->email = 'testemail1@moodle.com';
$user1->auth = 'manual';
$user1->idnumber = '';
$user1->lang = 'en';
$user1->timezone = 'Australia/Sydney';
$user1->mailformat = 0;
$user1->description = '';
$user1->city = '';
$user1->country = 'AU'; //list of abrevations is in yourmoodle/lang/en/countries
$preferencename1 = 'auth_forcepasswordchange';
$user1->preferences = array(
array('type' => $preferencename1, 'value' => 'true')
);
$users = array($user1);
$params = array('users' => $users);
/// REST CALL
$rest_format = 'json';
//$server_url = $domain_name . '/webservice/rest/server.php' . '?wstoken=' . $token . '&wsfunction=' . $function_name;
$server_url = 'localhost/moodle/my' . '/webservice/rest/server.php'. '?wstoken=' . '15bd45a3dab2958b7e8fc237b14f76cd' .'&wsfunction='. $functionName;
dpm($server_url);
require_once('curl.inc');
$curl = new curl;
$rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : '';
$resp =$curl($server_url . $rest_format, $params); //This is my line no 78
dpm($rest_format);
$respRc = json_decode($resp, true);
dpm($resp);
echo '</br>************************** Server Response createUser()**************************</br></br>';
echo $server_url . '</br></br>';
var_dump($resp);
}
第 78 行将 $curl(...) 替换为 new curl(..),您的对象实例化不正确。告诉 php 日志的是,您正在使用一个变量作为函数名称,又名 $curl(与 $functionName 无关,如果错误,稍后可能会生成错误,而 curl 不会编译)。
$resp = new curl($server_url . $rest_format, $params);