1
    ...
    ...        
    $page = curl_exec($ch);

    $DOM = new DOMDocument;
    $DOM->loadHTML($page);

    $xpath = new DOMXPath($DOM);

    $feeds = $xpath->query("//head/link[@href][@type='application/rss+xml']/@href");

    echo $feed->length;

I used curl and xpath, and it's broken in my server. It returned 1 in localhost, but blank in server. I have curl installed in my server.

jamie eason
  • 141
  • 10

1 Answers1

0

In your question you outline:

 print_r($feed->length);

It returned 1 in localhost, but blank in server.

Most likely you've got an error on your server. On your server you have to enable PHP error logging and set the error level to at least notices. Then you have to reproduce the "blank in server" situation. Afterwards you should find some error information in your error log, for example

Notice: Trying to get property of non-object

(this message is exemplary, yours might vary. You will be also given a filename where the error occurred and a line number.)

You can then use the PHP manual to review used functions, methods and language constructs at the location around the line where the error occurred and as well other curated resources like the PHP error reference we have on site to solve the issue.

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836