コード例 #1
0
ファイル: register.php プロジェクト: seans888/Bgy-Project
     //Good, no duplicate in database
 } else {
     $message = "Record already exists with the same primary identifiers!";
 }
 if ($message == "" and empty($arr_error)) {
     $dbh_citizen->add($arr_form_data);
     $citizen_id = $dbh_citizen->auto_id;
     require_once 'subclasses/validate.php';
     $dbh_citizen = new validate();
     for ($a = 0; $a < $validate_count; $a++) {
         $param = array('proof_of_id' => $cf_validate_proof_of_id[$a], 'proof_of_address' => $cf_validate_proof_of_address[$a], 'citizen_id' => $citizen_id, 'status' => $cf_validate_status[$a]);
         $dbh_citizen->add($param);
     }
     require_once 'subclasses/person.php';
     $dbh_person = new person();
     $dbh_person->add($arr_form_data);
     $person_id = $dbh_person->auto_id;
     $arr_form_data['person_id'] = $person_id;
     require 'password_crypto.php';
     //Hash the password using default Cobalt password hashing technique
     $hashed_password = cobalt_password_hash('NEW', $password, $username, $new_salt, $new_iteration, $new_method);
     $arr_form_data['password'] = $hashed_password;
     $arr_form_data['salt'] = $new_salt;
     $arr_form_data['iteration'] = $new_iteration;
     $arr_form_data['method'] = $new_method;
     $arr_form_data['role_id'] = 3;
     $arr_form_data['skin_id'] = 1;
     require_once 'subclasses/user.php';
     $dbh_user = new user();
     $dbh_user->add($arr_form_data);
     //Permissions from role, if role was chosen
コード例 #2
0
        return $res;
    }
    public function add($num1, $num2)
    {
        return $num1 + $num2;
    }
    public function findMax($arr)
    {
        //先假设数组中的第一个数,是最大的数。
        $maxVal = $arr[0];
        //这是最大数的下标值。
        $maxIdex = 0;
        for ($i = 1; $i < count($arr); $i++) {
            //如果认为的第一个最大的数小于了$i,则证明第一个数, 不是最大的数。
            if ($maxVal < $arr[$i]) {
                $maxVal = $arr[$i];
                $maxIdex = $i;
            }
        }
        return $maxVal;
    }
}
$p1 = new person();
$p1->speak();
$res = $p1->count1();
echo "计算结果是=" . $res;
$res = $p1->count2(5);
echo "<br/>计算结果是=" . $res;
echo "<br/>21+12=" . $p1->add(21, 12);
$myarr = array(21, 34, 45, 65, -2, -9);
echo "<br/>最大的下标值是" . $p1->findMax($myarr);