我試圖找出是否有可能&使用什麼樣的代碼:加載當前頁面的內容和回聲出一個相對路徑到一個特定的頁面(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