0

(またはコードの要点は次のとおりです。

$host = "";
...
xml_set_character_data_handler($xmlparser, "tagContents");
...
function tagContents($parser, $data) { 
    global $current; 
    global $host;
    if ($current == "HOST") { 
        $host = $data;         // Trying to store a global here
    }
    if ($current == "PATH") { 
        echo $host.$data;      // But its null when I get here.  WHY??
    }
}

xmlparse は各エコーの後に改行を挿入するため、このようにホストへのパスを追加して 1 行の URL を作成しようとしています。代わりに、誰かが改行を防ぐ方法を教えてくれれば、それも私の問題を解決するでしょう!

ところで:

ありがとう、ボブ

4

1 に答える 1

0

とにかく、スーパーグローバル$GLOBALS['host']をより高速に使用してみてください。これがあなたの固定コードです

$host = "";
...
xml_set_character_data_handler($xmlparser, "tagContents");
...
function tagContents($parser, $data) 
{ 
    global $current; 

    if ($current == "HOST") { 
        $GLOBALS['host'] = $data;         // Trying to store a global here
    }
    if ($current == "PATH") { 
        echo $GLOBALS['host'].$data;      
    }
}
于 2010-03-02T20:57:22.960 に答える