从当前页面获取特定的href

Trying to extract an href path (#navbar a href that ends in $pg) from the current page.

Getting a warning on the first foreach:

file_get_contents() [function.file-get-contents]: Filename cannot be empty.

How can I fix this?

<?php
include_once 'path/to/simple_html_dom.php';

$pg = 'c.html';
echo 'Page: ' . $pg . "<br />"; // Correct: c.html
$cpath = $_SERVER['REQUEST_URI'];
echo var_dump($cpath).": Current Path"."<br />";  // Correct: /copyr/index.php
$cfile = basename($cpath);
echo 'Current File: ' . $cfile . "<br />";  // Correct: index.php
$html = file_get_html($cfile);

foreach($html->find(sprintf('#navbar a[href=%s]', $pg)) as $path) {  // BROKEN
    echo 'Path: ' . $path."<br />";
    $tpath = $path."/".$pg;
    echo 'Total Path: ' . $tpath;
    $html->clear();
}

$html = file_get_html($tpath);

foreach($html->find('#testdiv2') as $ret) {
  echo $ret;
  $html->clear();
}

?>

basename returns the last part of a path. If REQUEST_URI ends in a / (as in http://yourdomain.arg/, basename returns an empty string, while file_get_html expects an uri or file name.