Warning: Illegal string offset 'handler' in C:\wamp\www\whois\whois\whois.gtld.php on line 57

走远了吗. 提交于 2019-12-12 02:23:29

问题


I'm using phpwhois php class to find whois details of web domains (http://sourceforge.net/projects/phpwhois/) and i'm using this script on my localhost. When i run this script using below code it shows an error. Please tell me where i am going wrong

Code

<?php
include('whois/whois.main.php');

$whois = new Whois();
$query = 'google.com';
$result = $whois->Lookup($query,false);
echo "<pre>";
var_dump($result);
echo "</pre>";
?>
  • And the error is

: Warning: Illegal string offset 'handler' in C:\wamp\www\whois\whois\whois.gtld.php on line 57


回答1:


The code at line 57 expects $query to be an array having an element 'handler'=>?
But the original query string is passed to that method, hence the illegal offset warning.
In the bug tracker at http://sourceforge.net/tracker/index.php?func=detail&aid=3605711&group_id=31207&atid=401654 a suggestion to fix this is to change

$this->SUBVERSION = sprintf('%s-%s', $query['handler'], $this->HANDLER_VERSION);

to

if (isset($query['handler'])) {
  $handler = $query['handler'];
} else {
  $handler = $query;
}
$this->SUBVERSION = sprintf('%s-%s', $handler, $this->HANDLER_VERSION);

But I haven't found any other occurence of the string SUBVERSION in the project, so I would just make that line a comment for now....




回答2:


Removing the line doesn't break anything since the SUBVERSION property isn't referenced anywhere else

reference phpwhois in github



来源:https://stackoverflow.com/questions/15654076/warning-illegal-string-offset-handler-in-c-wamp-www-whois-whois-whois-gtld-p

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!