English 中文(简体)
分析错误:语法错误,意外的T_CONSTANT_ENCAPSED_STRING,应为T_STRING或T_VARIABLE或{或$[closed]
原标题:Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or { or $ [closed]
  • 时间:2011-02-05 04:20:13
  •  标签:
  • php
  • parsing

从此简单Dom网站

if(isset($html-> div#sidebar )) 
{
    $sidebarFile =  D:xampphtdocsfinalwordpresssidebar.php ;
    $openSidebarFile = fopen($sidebarFile, a );
    foreach($html->find( div#sidebar )) as $e)
    {
        $html ->find( div[id=sidebar] , 0) -> innertext;
        $inputSidebar = $e->outertext;
        fwrite($openSidebarFile, "
" .inputSidebar "
");
    }
}

From the documentation: it says:

// Determine whether a attribute exist? 
if(isset($e->href)) 
        echo  href exist! ;
最佳回答

这里有几个问题,我将直接更正:

if($html->find( div#sidebar )) 
{
    $sidebarFile =  D:xampphtdocsfinalwordpresssidebar.php ;
    $openSidebarFile = fopen($sidebarFile, a );
    foreach($html->find( div#sidebar ) as $e)
    {
        $html ->find( div[id=sidebar] , 0) -> innertext;
        $inputSidebar = $e->outertext;
        fwrite($openSidebarFile, "
" .inputSidebar "
");
    }
} 

现在,发生了什么变化?第一个ifforeach。if使用了错误的函数,并且错误地检查了是否为空。foreach的()大括号不匹配。

问题回答

$html->;div#边栏你真的想要什么?在哪里找到

此外,您只能将isset与变量(或类似的事情,如数组访问)一起使用,而不能使用函数返回值。请改用





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签