我试图找出是否有可能&使用什么样的代码:加载当前页面的内容和回声出一个相对路径到一个特定的页面(c.html)这是瓦特/ “#navbar一个” 使用PHP或PHP Simple Html DOM Parser.PHP获取当前页面的具体内容
到目前为止我的代码:
<?php
$pg = 'c.html';
include_once '%resource(simple_html_dom.php)%';
/* $cpath = $_SERVER['REQUEST_URI']; Old version */ // Path to current pg from root
$cpath = "http://www.".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
echo var_dump($cpath).": Current Root Path"."<br />"; // "http://www.partiproductions.com/copyr/index.php" - Correct
$cfile = basename($cpath);
echo 'Current File: ' . $cfile . "<br />"; // "index.php" - Current pg, Correct
$html = file_get_html($cpath); // Getting Warning: URL file-access is disabled in the server configuration & failed to open stream: no suitable wrapper could be found in.. & Fatal error: Call to a member function find() on a non-object in...
foreach($html->find(sprintf('#navbar a[href=%s]', $pg)) as $path) {
echo 'Path: ' . $path."<br />";
}
?>
做'的print_r($ _ SERVER)',看看是否有任何值那里,你可以使用。 – Landon
尝试'$ html = file_get_html('index.php');'看看你是否有任何东西。如果没有,是否与您的脚本在同一个目录中是'index.php'?如果没有,请尝试获取'$ cpath'。 – cpilko
嗨@cpilko试图只是index.php,但没有奏效。 index.php是当前页面。在 – parti