[英]Displaying return from php script
I have this script: 我有这个脚本:
/** Key */
private $k = 't0kJKx27zm4ronxqXe';
/** Private salt */
private $p = 't0kez47ARpOxFnoVNJ';
private $host = 'http://url.com';
public function __construct()
{
;
}
public function generateUrl($iniciator = NULL)
{
$token = hash_hmac('sha1', date('Y-m-d') . $this->k, $this->p);
if($iniciator !== NULL)
{
if(!is_string($iniciator))
{
throw new \Exception('Iniciator must be string!');
}
}
return $this->host . 'a=' . $this->a . '&k=' . $token . '&u=' . $iniciator;
}
}
How do i echo/print... the string in return? 我如何回显/打印...返回的字符串?
return $this->host . 返回$ this-> host。 'a=' . 'a ='。 $this->a . $ this-> a。 '&k=' . '&k =' $token . $ token。 '&u=' . '&u =' $iniciator; $ initiator;
Your code is not complete it misses first line, something as: 您的代码不完整,缺少第一行,如下所示:
class Test {
Then you would run your code with: 然后,您将使用以下代码运行代码:
$someVar = new Test;
echo $someVar->generateUrl();
If you want to print from your class you can simply write echo instead of return: 如果要从您的班级打印,则可以简单地编写echo而不是return:
echo $this->host . 'a=' . $this->a . '&k=' . $token . '&u=' . $iniciator;
And then you would run your code with: 然后,您将使用以下代码运行代码:
$someVar = new Test;
$someVar->generateUrl(); // no need for echo because it's already in class
Warning: you have not defined variable $a in return. 警告:您尚未定义变量$ a作为回报。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.