调用未定义的函数 readline()? [英] Call to undefined function readline()?
本文介绍了调用未定义的函数 readline()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将 Dropbox 集成到我的基于 PHP 的网站中.当我尝试运行以下代码时.我在最后一行收到了这个致命错误:调用未定义的函数 readline().
require_once "dropbox-sdk/Dropbox/autoload.php";使用 \Dropbox 作为 dbx;$appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json");echo "";打印_r($appInfo);echo "</pre>";$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");echo "";print_r($webAuth);echo "</pre>";$authorizeUrl = $webAuth->start();echo "1. 转到:".$authorizeUrl ."\n
";echo "2. 单击\"允许\"(您可能需要先登录).\n
";echo "3. 复制授权码.\n
";$authCode = \trim(\readline("请在此处输入授权码:"));
我去过不同的论坛,人们说它可以在命令行中工作,但我不明白如何?有什么想法吗?
解决方案
或者直接用这个来模拟
if(!function_exists("readline")) {函数读行($prompt = null){如果($提示){回声 $prompt;}$fp = fopen("php://stdin","r");$line = rtrim(fgets($fp, 1024));返回 $line;}}
I am integrating Dropbox into my PHP based website. When i try to run the following code. i got this Fatal error: Call to undefined function readline() on the last line.
require_once "dropbox-sdk/Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json");
echo "<pre>";
print_r($appInfo);
echo "</pre>";
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
echo "<pre>";
print_r($webAuth);
echo "</pre>";
$authorizeUrl = $webAuth->start();
echo "1. Go to: " . $authorizeUrl . "\n<br>";
echo "2. Click \"Allow\" (you might have to log in first).\n<br>";
echo "3. Copy the authorization code.\n<br>";
$authCode = \trim(\readline("Enter the authorization code here: "));
I have come through different forum where people said it will work in Command line , But I don't understand how? Any idea ?
解决方案
Or just use this to simulate it
if(!function_exists("readline")) {
function readline($prompt = null){
if($prompt){
echo $prompt;
}
$fp = fopen("php://stdin","r");
$line = rtrim(fgets($fp, 1024));
return $line;
}
}
这篇关于调用未定义的函数 readline()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文