【问题标题】:Showing error: Unknown HTML tag显示错误:未知的 HTML 标记
【发布时间】:2014-12-08 03:38:23
【问题描述】:

所以我刚开始使用 Phpstorm,我正在尝试“更正”我的代码,以便 IDE 没有错误。我有下面的方法,我所有的 xml 标记都用 'Unknown HTML tag'

突出显示

纠正这个问题的最佳方法是什么?

private function generate_qbxml_CustomerAddRq($requestID=0){
                /** requestID is used when multiple requests are called in order to match the request to the response.
                    requestID's should be incremented as they are called. Currently not implimented. **/
                $qbxml  = '';
                $qbxml .= '<?xml version="1.0" encoding="utf-8"?>';
                $qbxml .= '<?qbxml version="2.0"?>';
                $qbxml .= '<QBXML>';
                $qbxml .=   '<QBXMLMsgsRq onError="stopOnError">';
                $qbxml .=       '<CustomerAddRq requestID="'.$requestID.'">';
                $qbxml .=           '<CustomerAdd>';
                $qbxml .=               '<Name>'.$this->Name.'</Name>'; //Name is a mandatory field. Add a check for this.
                /** For all optional values add a check so that xml tags are not sent in request if value is blank**/
                $qbxml .=               '<CompanyName>'.$this->CompanyName.'</CompanyName>';               
                $qbxml .=               '<FirstName>'.$this->FirstName.'</FirstName>';
                $qbxml .=               '<LastName>'.$this->LastName.'</LastName>';
                $qbxml .=               '<BillAddress>';
                $qbxml .=                   '<Addr1>'.$this->BillAddress->get_Addr1().'</Addr1>';
                $qbxml .=                   '<Addr2>'.$this->BillAddress->get_Addr2().'</Addr2>';
                $qbxml .=                   '<City>'.$this->BillAddress->get_City().'</City>';
                $qbxml .=                   '<State>'.$this->BillAddress->get_State().'</State>';
                $qbxml .=                   '<PostalCode>'.$this->BillAddress->get_PostalCode().'</PostalCode>';                                
                $qbxml .=                   '<Country>'.$this->BillAddress->get_Country().'</Country> ';                               
                $qbxml .=               '</BillAddress>';
                $qbxml .=               '<ShipAddress>';
                $qbxml .=                   '<Addr1>'.$this->ShipAddress->get_Addr1().'</Addr1>';
                $qbxml .=                   '<Addr2>'.$this->ShipAddress->get_Addr2().'</Addr2>';
                $qbxml .=                   '<City>'.$this->ShipAddress->get_City().'</City>';
                $qbxml .=                   '<State>'.$this->ShipAddress->get_State().'</State>';
                $qbxml .=                   '<PostalCode>'.$this->ShipAddress->get_PostalCode().'</PostalCode>';                                
                $qbxml .=                   '<Country>'.$this->ShipAddress->get_Country().'</Country> ';                               
                $qbxml .=               '</ShipAddress>';
                $qbxml .=               '<Phone>'.$this->Phone.'</Phone>';
                $qbxml .=               '<AltPhone>'.$this->AltPhone.'</AltPhone> ';
                $qbxml .=               '<Fax>'.$this->Fax.'</Fax> ';
                $qbxml .=               '<Email>'.$this->Email.'</Email> ';
                //$qbxml .=               '<JobDesc>Ob2</JobDesc>';
                $qbxml .=           '</CustomerAdd>';                
                $qbxml .=       '</CustomerAddRq>';
                $qbxml .=   '</QBXMLMsgsRq>';
                $qbxml .= '</QBXML>';

                return $qbxml;
            }

【问题讨论】:

    标签: phpstorm intellij-13


    【解决方案1】:

    您可以将字符串/var 标记为“语言注入”:

    1. 将插入符号放在字符串文字、标记或属性中,在 要注入语言并按 Alt+Enter (或使用 意图操作图标 意图操作图标)。
    2. 选择注入语言或参考并选择您想要的语言 注射。

    https://www.jetbrains.com/help/phpstorm/using-language-injections.html

    结果如下:

    $xmlString = /** @lang XML */
    '<?xml version="1.0" encoding="utf-8" ?>';
    

    【讨论】:

    • 这是一个比我原来的答案更好的解决方案。有人回应只花了 7 年多的时间;)。我已将此切换为正确答案。谢谢你。 (注:我很久以前就停止使用 phpstorm 了。)
    【解决方案2】:

    好吧,我自己想通了。

    Alt+Enter 然后选择 Add to custom HTML tags。

    类似于您处理拼写错误的方式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多