黃熊
<?php$url='';$html=file_get_contents($url);//print_r($http_response_header);ec($html);printhr();printarr($http_response_header);printhr();?> 示例代碼2: 用fopen打開url, 以get方式獲取內(nèi)容復制代碼 代碼如下: <?$fp=fopen($url,'r');printarr(stream_get_meta_data($fp));printhr();while(!feof($fp)){$result.=fgets($fp,1024);}echo"url body:$result";printhr();fclose($fp);?> 示例代碼3:用file_get_contents函數(shù),以post方式獲取url復制代碼 代碼如下: <?php$data=array('foo'=>'bar');$data=http_build_query($data);$opts=array('http'=>array('method'=>'POST','header'=>"Content-type: application/x-www-form-urlencodedrn"."Content-Length: ".strlen($data)."rn",'content'=>$data),);$context=stream_context_create($opts);$html=file_get_contents('',false,$context);echo$html;?>
路乙
$content = file_get_contents($file); //讀文件$content = $content . '正在修改'; //修改文件file_put_contents($file, $content); //保存文件本回答被網(wǎng)友采納
騰蛇環(huán)
如果是想獲取當前文件的父文件夾名可以使用basename(__DIR__);如果是兄弟文件夾,可以用glob(__DIR__.'*');獲取兄弟文件(夾),使用is_dir判斷文件夾,從而獲取文件夾名稱,其他上層文件夾名可以使用explode('/', str_replace("\\", "/", __DIR__));各個上層文件夾的名字根據(jù)層次索引存在數(shù)組中
鏡澄
用javascript形式輸出數(shù)據(jù),其實那就是php把js的輸出腳本變?yōu)樽址男问?,當js調(diào)用會執(zhí)行php代碼例如:輸出的php文件demo.phpecho 'document.write("'.define('WP_USE_THEMES', false);.'")';echo 'document.write("'.require('article/wp-blog-header.php');.'")';echo 'document.write("'.query_posts('showposts=20');.'")';其它的都是這樣寫就行了html頁面js調(diào)用demo.php<script type="text/javascript" src="demo.php"></script>
那為什么html文件不能識別php的默認格式,會報無法識別<這個錯
錢謙益
get_included_files 返回被 include和require文件名的array
說明
get_included_files ( void ) : array
返回所有被 include、 include_once、 require 和 require_once 的文件名。
返回值
返回所有文件名稱的 array。
腳本最初被稱為”被包含的文件“,所以腳本自身也會和 include 系列函數(shù)引用的腳本列在一起,被多次 include 和 require 的文件在返回的 array 里只會列出一次。
擴展資料:
程序示例
<?php
include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';
$included_files = get_included_files();
foreach ($included_files as $filename) {
echo "$filename\n";
}
?>
孫冀
顯示本文件夾下的A.JPG的語句:
echo "<img src='a.jpg' />";
可能你已經(jīng)明白了,其實PHP輸出的是HTML代碼,PHP無需具體讀取文件內(nèi)容,也無法在客戶的瀏覽器上繪圖,這一切只有交給瀏覽器去實現(xiàn)。
要的不是這個
夏侯楙
利用PHP讀取文本文件的內(nèi)容,其實很簡單,我們只需要掌握函數(shù)“file_get_contents();”的使用就可以了。下面,小編將作詳細的介紹。 工具/原料 電腦一臺 WAMP開發(fā)環(huán)境 方法/步驟 file_get_content()函數(shù)介紹。使用file_get_contents()獲取txt文件的內(nèi)容,具體參數(shù)說明如下: 2 具體實例說明。從文本文件tst.txt中讀取里面的內(nèi)容并顯示在瀏覽器中,具體代碼和圖示如下: <?php $file = 'tst.txt'; $content = file_get_contents($file); //讀取文件中的內(nèi)容 echo $content; ?>
妖氛盡掃
把文本里面的內(nèi)容改成<p><strong> Your order could not be processed at this time.Please try again later.</strong></p>
<p><strong> Your order could not be processed at this time.Please try again later.</strong></p>
<?php echo date('H:i,jS F Y'); ?>
網(wǎng)頁上的顯示變?yōu)椋?/p>
我是說你右鍵查看源代碼看看有沒有生成什么,就是查看生成的html文本文件
你當前的這個文件是html的靜態(tài)頁嗎?
讀取的代碼保存成.php格式的。讀取的文件時evil.txt格式。
那你看這樣行不行you did not Your order could not be processed at this time.Please try again later.".date('H:i,jS F Y').""還是不行啊,改成".date('H:i,jS F Y').""之后,顯示成
Bob's auto parts-customer ordersBob's auto partscustomer ordersno orders pending.please try again later.";exit;}$order="";while(!feof($fp)){$order=$order.fgets($fp,999);}echo $order;?>文本里面的內(nèi)容改成you did not Your order could not be processed at this time.Please try again later.試試還是不行啊。。。。
好像你說的這種方法在文本里面套php函數(shù)變量的思想行不通哦
玉桿真人
進入php源程序目錄中的ext目錄中,這里存放著各個擴展模塊的源代碼,選擇你需要的模塊,比如curl模塊:cd curl 執(zhí)行phpize生成編譯文件,phpize在PHP安裝目錄的bin目錄下 /usr/local/php5/bin/phpize 運行時,可能會報錯:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.,需要安裝autoconf: yum install autoconf(RedHat或者CentOS)、apt-get install autoconf(Ubuntu Linux) /usr/local/php5/bin/php -v 執(zhí)行這個命令時,php會去檢查配置文件是否正確,如果有配置錯誤,這里會報錯,可以根據(jù)錯誤信息去排查!