【php – 如何使用Zend_Mail发送附件?】教程文章相关的互联网学习教程文章

php使用数据库配置文件的方法【图】

介绍:将数据库用户名、密码等保存在配置文件config.php中,然后在需要的地方使用include或require包含进来,并在函数里用global关键字将存放数据库名,密码等的变量全局化,便可以在文件里的函数中使用了。介绍:将数据库用户名、密码等保存在配置文件config.php中,然后在需要的地方使用include或require包含进来,并在函数里用global关键字将存放数据库名,密码等的变量全局化,便可以在文件里的函数中使用了。1、配置文件-conf...

php使用file_exists检查文件或目录是否存在

$filename = '/jbxue.com/aa/to/foo.txt';if (file_exists($filename)) {echo "文件$filename exists";} else {echo "文件$filename 不存在";}?>输出结果: 文件/jbxue.com/aa/to/foo.txt己存在 例2:echo file_exists("jbxue.com.txt");?> 直接用file_exists来返回ture or false

php使用ftp函数创建目录(生成静态)

/*** desc:create directory through FTP connection* link:bbs.it-home.org* date:2013/02/24*/function FtpMkdir($path, $newDir) { $server='ftp.yourserver.com'; // ftp server $connection = ftp_connect($server); // connection // login to ftp server $user = "me"; $pass = "password"; $result = ftp_login($connection, $user, $pass); // check if connection was made if ((!$conn...

php使用header函数设置各种HTTP头的例子

/** desc:header函数设置各种HTTP头 link:bbs.it-home.org date:2013/2/24*///定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/atom+xml'); //CSS header('Content-type: text/css'); //Javascript header('Content-type: text/javascript'); //JPEG Image header('Content-type: image/jpeg'); //JSON header('Content-type: application/json...

php使用header发送各种类型文件下载的例子

header('Content-type: application/image/pjpeg');//输出的类型 header('Content-Disposition: attachment; filename="downloaded.jpg"'); //下载显示的名字,注意格式 readfile('my.jpg'); // 并将这个文件以前面header发送信息设定的类型输出,从而会弹出一个下载框 // 就是把服务器上的my.jpg下载下来,下载显示和保存的名字默认是downloaded.jpg ?> 所谓实现文本文件的下载就是说当我们点击一个文本文件的链接的时候不是打...

php使用PDO操作数据库的类(Mysql下适用)

/*** 作者:胡睿* 日期:2012/07/21* 电邮:hooray0905@foxmail.com*/class HRDB{protected $pdo;protected $res;protected $config;/*构造函数*/function __construct($config){$this->Config = $config;$this->connect();}/*数据库连接*/public function connect(){$this->pdo = new PDO($this->Config['dsn'], $this->Config['name'], $this->Config['password']);$this->pdo->query('set names utf8;');//把结果序列化成stdCla...

php使用EasyUIDataGrid获取资料的方式

一條小龍 easyUI datagrid一條小龍 easyUI datagrid url test<table id="tt" class="easyui-datagrid" style="width:750px;height:300px"url="datagrid2_getdata.php" title="Load Data" pagination="true">UNumUser IDPasswordBirthdayNicknameDBSTS

php使用phpword生成word文档的例子

require_once '../libs/PHPWord/PHPWord.php';require_once '../libs/PHPWord/PHPWord/IOFactory.php';require_once '../../config.php';// require_once '../common/conn.php';// New Word Document$PHPWord = new PHPWord();/**********文本格式的word text.php************/// New portrait section//逗号 分割字符串$arr = $_REQUEST['arr'];$a = explode(',',$arr);//echo $arr;date_default_timezone_set("Asia/Shanghai");/...

php使用mysql_data_seek将指针移动到数据集初始位置的代码

// Start snipit 1$sql = "SELECT * from ";$result = mysql_query($sql);while ($row = mysql_fetch_assoc($result)) {// do stuff with $row}mysql_data_seek($result, 0); //关键是这儿while ($row = mysql_fetch_assoc($result)) {// do other stuff with $row}?>定义和用法 mysql_data_seek() 函数移动内部结果的指针。 语法 mysql_data_seek(data,row)参数 描述 data 必需。返回类型为 resource 的结果集。该结果集从 mysql_...

php使用curl判断远程文件是否存在的代码

//判断远程文件function check_remote_file_exists($url){$curl = curl_init($url);// 不取回数据curl_setopt($curl, CURLOPT_NOBODY, true);// 发送请求$result = curl_exec($curl);$found = false;// 如果请求没有发送失败if ($result !== false) {// 再检查http响应码是否为200$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);if ($statusCode == 200) {$found = true;}}curl_close($curl);return $found;}?>最近在弄一...

php使用curl伪造IP来源的代码

$ch = curl_init();$url = "http://localhost/target_ip.php";$header = array('CLIENT-IP:58.68.44.61','X-FORWARDED-FOR:58.68.44.61',);curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HTTPHEADER, $header);curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);$page_content = curl_exec($ch);curl_close($ch);echo $page_content;?>请求的目标文件---target_ip.php:echo getenv('HTTP_CLIENT_IP');echo getenv('...

php使用phpMailer发送邮件的例子

require("phpmailer/class.phpmailer.php"); function smtp_mail( $sendto_email, $subject, $body, $extra_hdrs, $user_name){ $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.163.com"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "xuchao842363331"; // SMTP user...

php使用mkdir创建多级目录的方法

mkdir("/path/to/my/dir", 0700);?>如果成功则返回 TRUE,失败则返回 FALSE。 注意: 自 PHP 5.0.0 rmdir() 也可用于某些 URL 封装协议。参见附录 N 的列表看看 rmdir() 支持哪些 URL 封装协议。 注意: 对 context 的支持是 PHP 5.0.0 添加的。有关 context 的说明见参考 CLX, Stream Functions。 注意: recursive 参数是 PHP 5.0.0 添加的。 注意: 当安全模式被激活时,PHP 将检查被操作的目录是否和正在执行的脚本有相同的 UID(...

php使用ftp下载文件的简单例子

为大家举一个php使用ftp函数下载文件的例子,练习php中ftp函数的用法,供初学的朋友参考。代码如下:

php使用cookie统计访问者登陆次数的代码举例

$_COOKIE["counter"]?($c=$_COOKIE["counter"]+1):($c=1);setCookie("counter",$c,time()+60);echo "欢迎您第"."".$c."次访问cookie";//by bbs.it-home.org?>下面是有关这个例子的代码说明,供大家参考。 以上代码中,首先,浏览器请求一个资源(这个php页面),发送下面的HTTP包头内容到服务器: GET http://localhost/index.php HTTP/1.1 HOST:localhost Accept:*/* Accept-language:zh-cn Accept-Encoding:gzip,deflate User-Ag...