我有我加载索引文件后包含的PHP文件,我在那个php文件中的某个时刻调用了一个函数,现在一切都很好了
但是当被调用的函数试图在同一个php文件中调用另一个函数时,函数调用似乎永远不会发生,这就是我所说的:
<?php
ini_set('display_errors', 1);
global $logger;
$logger->info("inside user.php");
//require_once("./vendor/wixel/gump/gump.class.php");
require_once("./bizDataLayer/gameBizData.php");
require "./bizDataLayer/dbInfoPS.inc";//to use we need to put in: global $mysqli;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @global type $logger
* @param type $d API data as JSON
* @param type $ip user IP address
* @param type $token user token
*/
function registerUser($d, $ip, $token) {
global $logger;
$logger->debug("insider registerUser() function");
//Check if data is valid
$data=validateData($d); /////////////////////This call seems to never work
if(!$data){
$errorMsg = array(
'error' =>'Data send is invalid.'
);
$logger->info("user exist error as".$errorMsg);
return json_encode($errorMsg);
}
$logger->debug("The data has been validated -- about to insert into DB");
// Prepared data for the database use
// Hash password
$password_hash = password_hash($validated_data['password1'], PASSWORD_BCRYPT);
$logger->debug("Hashed password: '".$password_hash."'");
$userData = array(
'firstName' => $data['firstName'],
'lastName' => $data['lastName'],
'email' => $data['email'],
'password' => $password_hash,
'status' => 1,
'registration_date' => date('Y-m-d G:i:s')
);
return insertUser($userData);
}
//this is the function I call
function validateData($data){
$logger->debug("insider validateDatar() function"); //loggin out if the function is call ,but it is not
$gump = new GUMP();
// $logger->info("gump:".$gump);
$data = $gump->sanitize($data); // You don't have to sanitize, but it's safest to do so.
$gump->validation_rules(array(
'firstName' => 'required|alpha_numeric|max_len,100|min_len,6',
'lastName' => 'required|max_len,100|min_len,6',
'email' => 'required|valid_email',
'password' => 'required|max_len,100|min_len,6',
'status' => 'required|integer'
));
$gump->filter_rules(array(
'firstName' => 'required|alpha_numeric|max_len,100|min_len,6',
'lastName' => 'required|max_len,100|min_len,6',
'email' => 'required|valid_email',
'password' => 'required|max_len,100|min_len,6',
'status' => 'required|integer'
));
$validated_data = $gump->run($data);
if($validated_data === false) {
return false;
}
else {
return $validated_data;
}
}
当我检查我的日志时,函数validateData()&#39;看起来好像从未被称为。我似乎不明白为什么。
以下是完整的项目: