宽松标题,不知道如何放置它。本质上,我无法在现有的PHP代码之后写任何东西(其中包含类,几个函数和函数回声)。我尝试了基本的html,还有更多的PHP,它都无法正常工作。
记住我何时做python,看来这是一个仍在运行的循环,从而阻止其他任何事情都无法正常工作。
我的代码:
<?php
//We're using a newer and older generation algorithms in order to create different results
//The time and date is used as a basic "salting" mechanism, which will make the number hard to determine without knowing the generation time
//I should consider using more secure generation, such as "random_int"
//EXTREMELY WIP!!!
class authGeneration
{
private function gen($maxOne) {
$begin_value_one = date("sih") * rand(1,100);
$auth_value_one = mt_rand($begin_value_one, $maxOne);
echo $auth_value_one;
}
private function genAdd($maxTwo) {
$begin_value_two = date("his") + mt_rand(1000,1000000);
$auth_value_two = rand($begin_value_two, $maxTwo);
echo $auth_value_two;
}
public function finalGen() {
$begin_value_three = date("dmY");
$auth = $this->gen(999999999) + $this->genAdd(999999999); //No more than 999999999, no less than 100000000 (for both)
$add = $auth + $begin_value_three;
echo parseFloat ($add);
}
}
function authCode() {
$obj = new authGeneration();
echo $obj->finalGen();
}
echo "Authentication code: "; authCode();
echo "MD5 Checksum: "; md5(authCode); //Doesn't work :(
authCode();
的第一个回声可起作用,但是,无论我在那里写什么,下面的行都没有。关于问题是什么?或者,如果是上述"循环",我该如何逃脱?随意概述我的愚蠢。
注意,PHP不是我的专业,我主要使用Java和/或C#(因为它们比PHP更有趣),只是决定在PHP中做一些有趣的事情,因此语言的知识相对有限。
尝试在脚本末尾运行以下内容。
echo "Authentication code: " . authCode();
echo "MD5 Checksum: " . md5(authCode());
我相信您只是没有正确地将PHP附加到Echo语句中为';'表示php中的线结束。
进一步查看后,您的第二个实例的Authcode遗漏了开口和关闭括号。
最好返回AuthCode()函数中的字符串并设置等于变量的结果SET AUTHCODE(),以便您不调用AuthCode()Funciton两次。例如:
function authCode() {
$obj = new authGeneration();
return $obj->finalGen();
}
var $authvar = authCode();
echo "Authentication code: " . authvar;
echo "MD5 Checksum: " . md5(authvar);