rombatomba / rolling-curl

Automatically exported from code.google.com/p/rolling-curl
0 stars 0 forks source link

Undefined variable in example.php if missing page title #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Fetch a URL that is wrong, or the HMTL $response is missing <title> tags, or 
if there is a server configuration issue that is breaking cURL
2. Run example.php

What is the expected output? What do you see instead?

No output, as expected, but PHP raises:
PHP Notice:  Undefined variable: title in /example.php on line 19

What version of the product are you using? On what operating system?

r20 Sep 12, 2010 on CentOS 6.2

Please provide any additional information below.

The PHP notice can be fixed by moving the echo $title inside the if block. e.g.,

  if (preg_match("~<title>(.*?)</title>~i", $response, $out)) {
    $title = $out[1];
    echo "<b>$title</b><br />";
  } else {
    echo "<i>page title not found</i><br />";
  };

Original issue reported on code.google.com by nickcons...@googlemail.com on 12 Apr 2014 at 11:21