Php高手帶路--問題匯總解答(2)_PHP教程
推薦:十天學(xué)會php之第十天 文本關(guān)鍵字:程序設(shè)計/PHP/技巧 學(xué)習(xí)目的:學(xué)會用PHP上傳文件和發(fā)郵件 上傳文件表單必須加上 enctype="multipart/form-data" 和 <input type="file" na
4:為什么我向另一網(wǎng)頁傳送變量時,只得到前半部分,以空格開頭的則全部丟失PHP代碼:
<?php
$Var="hello php";//修改為$Var=" hello php";試試得到什么結(jié)果
$post= "receive.php?Name=".$Var;
header("location:$post");
?>
receive.php的內(nèi)容:
PHP代碼:
<?PHP
Echo "<pre>";
Echo $_GET["Name"];
Echo "</pre>";
?>
正確的方法是:
PHP代碼:
<?php
$Var="hello php";
$post= "receive.php?Name=".urlencode($Var);
header("location:$post");
?>
在接收頁面你不需要使用Urldecode(),變量會自動編碼.
5:我怎么知道系統(tǒng)默認(rèn)支持什么函數(shù)
PHP代碼:
<?php
$arr = get_defined_functions();
Function php() {
}
echo "<pre>";
Echo "這里顯示系統(tǒng)所支持的所有函數(shù),和自定以函數(shù)php\n";
print_r($arr);
echo "</pre>";
?>
PHP代碼:
<?PHP
$Date_1="2003-7-15";//也可以是:$Date_1="2003-7-15 23:29:14";
$Date_2="1982-10-1";
$d1=strtotime($Date_1);
$d2=strtotime($Date_2);
$Days=round(($d1-$d2)/3600/24);
Echo "偶已經(jīng)奮斗了 $Days 天^_^";
?>
7:為什么我升級PHP后,原來的程序出現(xiàn)滿屏的 Notice: Undefined variable:
這是警告的意思,由于變量未定義引起的.
打開php.ini,找到最下面的error_reporting,修改為error_reporting = E_ALL & ~E_NOTICE
對于Parse error錯誤
error_reporting(0)無法關(guān)閉.
如果你想關(guān)閉任何錯誤提示,打開php.ini,找到display_errors,設(shè)置為display_errors = Off.以后任何錯誤都不會提示.
那什么是error_reporting?
8:我想在每個文件最前,最后面都加上一文件.但一個一個添加很麻煩
1:打開php.ini文件
設(shè)置 include_path= "c:"
2:寫兩個文件
auto_prepend_file.php 和 auto_append_file.php 保存在c盤,他們將自動依附在每個php文件的頭部和尾部.
3:在php.ini中找到:
Automatically add files before or after any PHP document.
auto_prepend_file = auto_prepend_file.php;依附在頭部
auto_append_file = auto_append_file.php;依附在尾部
以后你每個php文件就相當(dāng)于
PHP代碼:
<?php
Include "auto_prepend_file.php" ;
.......//這里是你的程序
Include "auto_append_file.php";
?>
分享:十天學(xué)會php之第九天 文本關(guān)鍵字:程序設(shè)計/PHP/技巧 學(xué)習(xí)目的:注意事項 因為我是先學(xué)ASP的,所以再做PHP的時候會發(fā)現(xiàn)很多地方需要適應(yīng)。 1、注意不要漏了分號 2、注意不要漏了變量前
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-Php高手帶路--問題匯總解答(2)
。