首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >注意:尝试访问第300行/opt/lampp/htdocs/about/include/whois.php中int类型值的数组偏移量

注意:尝试访问第300行/opt/lampp/htdocs/about/include/whois.php中int类型值的数组偏移量
EN

Stack Overflow用户
提问于 2020-06-23 17:43:46
回答 2查看 199关注 0票数 1

我试图编写一个PHP代码,用"\n"将所有的行都炸开,并在其中添加一个<hr>标记。这就是代码的工作方式:

  1. 它是一个简单的代码,可以从一个无名服务器请求数据,并将查询与其域扩展相匹配。例如,对于www.google.com,它将接受.com部件,并尝试将其与不同的扩展匹配。此外,它也搜索其他数据。
  2. 现在,我想添加一些<hr>标签,以分离,并使其适合我的网站。

这是我查询facebook.com时的结果

代码语言:javascript
复制
Domain Name: FACEBOOK.COM
Registry Domain ID: 2320948_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.registrarsafe.com
Registrar URL: http://www.registrarsafe.com
Updated Date: 2020-03-10T18:53:59Z
Creation Date: 1997-03-29T05:00:00Z
Registry Expiry Date: 2028-03-30T04:00:00Z
Registrar: RegistrarSafe, LLC
Registrar IANA ID: 3237
Registrar Abuse Contact Email: abusecomplaints@registrarsafe.com
Registrar Abuse Contact Phone: +1-650-308-7004
Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
Name Server: A.NS.FACEBOOK.COM
Name Server: B.NS.FACEBOOK.COM
Name Server: C.NS.FACEBOOK.COM
Name Server: D.NS.FACEBOOK.COM
DNSSEC: unsigned
URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2020-06-23T17:31:31Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.
The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

现在我想用一些PHP代码来美化它。我想把这些数据分成几个小部分。

代码语言:javascript
复制
<!-- Basic Details -->
Domain Name: FACEBOOK.COM
Registry Domain ID: 2320948_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.registrarsafe.com
Registrar URL: http://www.registrarsafe.com
Updated Date: 2020-03-10T18:53:59Z
Creation Date: 1997-03-29T05:00:00Z
Registry Expiry Date: 2028-03-30T04:00:00Z
Registrar: RegistrarSafe, LLC
Registrar IANA ID: 3237
Registrar Abuse Contact Email: abusecomplaints@registrarsafe.com
Registrar Abuse Contact Phone: +1-650-308-7004


<hr>
<!-- Domain Status -->  
...

<hr>
<!-- Other Details -->
...

我注意到,当您更改域名时,行数不会改变。所以我试着把前十行分开。接下来的4行,等等。并添加

中间的标签。

我的程序收集的数据,存储在一个$result变量中。这是我的密码

代码语言:javascript
复制
    $detailedProperties = [];
    $finalArray = [];
    $words = explode("\n", $result);
    array_push($detailedProperties, $words);
    $lengthOfWords = count($detailedProperties);
    for ($i = 0; $i < $lengthOfWords; $i++) {
        if((string)$i[0]) {
            
            $value = '<div class="container">'.
                    '<hr>'.     
                '</div>';
                array_push($finalArray, $value) ;
        }
        $value = "$i[0]"."\n"."$i[1]"."\n"."$i[2]"."\n"."$i[3]"."\n"."$i[4]"."\n"."$i[5]"."\n"."$i[6]"."\n"."$i[7]"."\n"."$i[8]"."\n"."$i[9]"."\n";
        array_push($finalArray, $value);
        if($i[10]) {
            
            $value = '<div class="container">'.
                    '<hr>'.     
                '</div>';
                array_push($finalArray, $value) ;
        }
        if($i[16]) {
            
            $value = '<div class="container">'.
                    '<hr>'.     
                '</div>';
                array_push($finalArray, $value) ;
        }
        if($i[20]) {
            
            $value = '<div class="container">'.
                    '<hr>'.     
                '</div>';
                array_push($finalArray, $value) ;
        }
    }
    
    return 
        "<div class='row cta-content'>".
            "<div class='offerdescription'>".
                "<div class='container' style='font-size:20px'>".
                    // $detailedProperties;
                    
                    "<span class='search-results'><strong>$domain</strong> Domain lookup results from <strong>$whoisserver</strong> Server\n\n</span>" . $finalArray.
                "</div>".
            "</div>".
        "</div>";

现在,错误日志:

代码语言:javascript
复制
Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 300

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 307

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 309

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 316

Notice: Trying to access array offset on value of type int in /opt/lampp/htdocs/about/include/whois.php on line 323

Notice: Array to string conversion in /opt/lampp/htdocs/about/include/whois.php on line 338

这些程序打印的是Array,而不是我上面附加的数据。( facebook数据)

你能告诉我我做错了什么吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-06-23 18:19:19

这可能会被缩短和/或改进,但它比您拥有的更好:

代码语言:javascript
复制
$lines = explode("\n", $result);
$value = "\n<div class='container'><hr></div>\n";
$output[] = implode("\n", array_slice($lines, 0, 11));  //get first 11
$output[] = implode("\n", array_slice($lines, 11, 6));  //get next 6
$output[] = implode("\n", array_slice($lines, 17));     //get remaining
$finalArray = implode($value, $output);

return 
    "<div class='row cta-content'>
        <div class='offerdescription'>
            <div class='container' style='font-size:20px'>
                <span class='search-results'><strong>$domain</strong> Domain lookup results from <strong>$whoisserver</strong> Server\n\n</span>
                $finalArray
            </div>
        </div>
     </div>";
票数 1
EN

Stack Overflow用户

发布于 2020-06-23 17:51:36

$i[10]是语法错误,$m[n]表示检索具有关联键n的$m数组值。

应该是这样的:

代码语言:javascript
复制
if($i <= 10) {
    //...
} elseif($i > 10 && $i <=16) {
    //...
} else {
    //...
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62540750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档