目前分類:PHP筆記 (6)

瀏覽方式: 標題列表 簡短摘要

【資料來源 :http://www.real-blog.com/programming/416 】

PHPMailer 是一個功能豐富的函式庫,以下是用 PHPMailer 通過遠端 SMTP 認證發送郵件的例子:

PHP:
  1. <?php
  2. // 建立 PHPMailer 物件及設定 SMTP 登入資訊
  3. require("../phpMailer/class.phpmailer.php");
  4. $mail = new PHPMailer();
  5. $mail->IsSMTP()// send via SMTP

戮克 發表在 痞客邦 留言(0) 人氣()

摘要: 用文本框接收用户的提交信息,有时候内容需要换行,我们可以用nl2br函数来将内容中的换行\n 替换成<br />。 这里要注意的是nl2br函数不是真正的替换而是在\n之前插入<br />  原来的 \n就依然存在 用户提交以后再编辑,这时候我们的程序是采用从数据库中读出信息后 先将<br...
 

用文本框接收用户的提交信息,有时候内容需要换行,我们可以用nl2br函数来将内容中的换行\n 替换成<br />。

这里要注意的是nl2br函数不是真正的替换而是在\n之前插入<br />  原来的 \n就依然存在

用户提交以后再编辑,这时候我们的程序是采用从数据库中读出信息后 先将<br />替换成 \n 再输出到编辑框 ,这样原来只有一个\n的就变成了两个\n 此时写入文本框 就多出了一个换行。

所以个人建议采用str_replace进行替换  ,或者你们有更好的方法,请给我留言。

欢迎转载,转载请保留链接: http://www.phpzu.com/php/phpspecial/article-792.html

戮克 發表在 痞客邦 留言(0) 人氣()

[From: http://www.phpchina.com/html/20/12020-16121.html]

require()
require() is identical to include() except upon failure it will produce a fatal E_ERROR level error. In other words, it will halt the script whereas include() only emits a warning (E_WARNING) which allows the script to continue.

 

這幾個的區別呢 經常會聽到有人討論

連一些PHPER面試都會出這個題目

我淺顯的說一下我的意見

先看手冊怎麼說的:
include&require

include()語句包含並運行指定文件。

戮克 發表在 痞客邦 留言(0) 人氣()

HTTP redirects usually have the response status 301 or 302 and provide the redirection URL in the “Location” header. I’ve written three complementary PHP functions that you can use to find out where an URL redirects to (based on a helpful thread at WebmasterWorld). You don’t even need CURL for this – fsockopen() will do just fine.

The PHP script
/**
* get_redirect_url()
* Gets the address that the provided URL redirects to,
* or FALSE if there's no redirect.
*
* @param string $url
* @return string
*/

戮克 發表在 痞客邦 留言(0) 人氣()

 

<?php

define(SUM, 1000); //需要訪問的次數
define(L_TIME, 1000); //強制腳本執行的時間
define(S_TIME, 1); //每次訪問之間休眠的時間
$url = "HTTP://www.xxx.com/Article/GetHits.asp?ArticleID=759"; //需要訪問的位址
set_time_limit(L_TIME);

 

//訪問指定URL函數knowsky.com
function access_url($url)

戮克 發表在 痞客邦 留言(0) 人氣()

最近使用PHP再POST進去的字串一直亂碼
最後查了一下發現PHP版本不同設定編碼的寫法也不同...
最後一次把大部分設定編碼語法都寫進去才解決


header("Content-Type:text/html; charset=utf-8");
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER_SET_CLIENT=utf8");
mysql_query("SET CHARACTER_SET_RESULTS=utf8");

戮克 發表在 痞客邦 留言(0) 人氣()