admin
2010.06.04
Php, 技术文档
接收xml:
$xml = file_get_contents(‘php://input’);
发送(post):
$xml_data = “<xml>…</xml>”;
$url = “http://dest_url”;
$header[] = “Content-type: text/xml”;//定义content-type为xml
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
$response = curl_exec($ch);
if(curl_errno($ch))
{
print curl_error($ch);
}
curl_close($ch);
或者:
$fp = fsockopen($server, 80);
fputs($fp, “POST $path HTTP/1.0\r\n”);
fputs($fp, “Host: $server\r\n”);
fputs($fp, “Content-Type: text/xml\r\n”);
fputs($fp, “Content-Length: $contentLength\r\n”);
fputs($fp, “Connection: close\r\n”);
fputs($fp, “\r\n”); // all headers sent
fputs($fp, $xml_data);
$result = ”;
while (!feof($fp)) {
$result .= fgets($fp, 128);
}
return $result;
admin
2010.05.31
Php, 技术文档
首先验证码的原理就是,画一张图片,然后在这张图片上写一些字,然后加一些干扰的线条,像素点之类的东西就ok了,
这里要使用 php那就要知道php中画图的函数是那些,然后拿来用便是了。
如果要用php的画图函数,首先要启用这个模块的功能。就是把 php.ini中php_gd2.dll前面的注释去掉就好了。
下面开始画图: 继续阅读 »
admin
2010.05.27
Php, 技术文档
1. 分号的例外
对于 MySQL ,第一件你必须牢记的是它的每一行命令都是用分号 (;) 作为结束的,但……没有完全绝对的事,在这儿也是一样,当一行 MySQL 被插入在 PHP 代码中时,最好把后面的分号省略掉,例如:
mysql_query (“INSERT INTO tablename (first_name, last_name)
VALUES (‘$first_name’, ‘$last_name’)
“);
这是因为 PHP 也是以分号作为一行的结束的,额外的分号有时会让 PHP 的语法分析器搞不明白,所以还是省略掉的好。在这种情况下,虽然省略了分号,但是 PHP 在执行 MySQL 命令时会自动的帮你加上的。
继续阅读 »
admin
2010.05.26
Php, 技术文档
< ?
class document{
private $file_array=array();
private $folder_array=array();
private $all_array=array();
function search($path,$file){
if(is_dir($path)){
$H=opendir($path);
while(false!==($_file=readdir($H))){
if(is_dir($path."/".$_file)&&$_file!="." && $_file!=".." && $_file!=="Thumbs.db"){
if(eregi($file,$path."/".$_file)){
array_push($this->folder_array,$path."/".$_file);
}
$this->search($path."/".$_file,$file);
}elseif(is_file($path."/".$_file)&&$_file!="." && $_file!=".." && $_file!=="Thumbs.db"){
if(eregi($file,$_file)){
array_push($this->file_array,$path."/".$_file);
}
}
}
$this->all_array["folder"]=$this->folder_array;
$this->all_array["file"]=$this->file_array;
return $this->all_array;
closedir($H);
}elseif(is_file($path)){
if(eregi($file,$path)){
$this->all_array["file"]=$path;
}
return $this->all_array;
}else{
return $this->error("this folder does not exits,please check it out.");
}
}
}
?>
函数描述及例子
继续阅读 »
admin
2010.05.26
Linux, Php, 技术文档
搜索引擎是为用户提供快速获取网页信息的工具,其主要的功能是系统通过用户输入关键字,检索后端网页数据库,将相关网页的链接和摘要信息反馈给用户。从搜 索的范围上一般分为站内网页搜索和全局网页搜索。随着网页数量的急剧增加,搜索引擎已经成为上网查询信息的必须手段,各个大型网站均已经提供网页数据搜索 服务,并且出现了许多为大型网站提供专业搜索引擎服务的公司,如为Yahoo提供搜索服务的Google,为新浪网和263等国内网站提供服务的百度公司 等。专业的搜索服务费用高而免费的搜索引擎软件基本都是基于英文的检索,所以都不太适合Intranet环境(如校园网等)的需要。
搜索引擎的基本组成一般分为网页收集程序、网页后端数据组织存储、网页数据检索三部分。决定搜索引擎好坏的关键因素是数据查询的响应时间,即如 何组织好满足全文检索需要的大量网页数据。 继续阅读 »
admin
2010.05.25
Php, 技术文档
Zip:PclZiphttp://www.phpconcept.net/pclzip/index.en.php
Rar:PECL rarhttp://pecl.php.net/package/rar
以 往过去要在php下 执行解压缩程序,无非最常见的方法是写command 然后用exec()等执行函式去跑
这在Windows下或许可以,但换成Unix话会碍於帐号权限问题而无法顺利执行
那有没有那种本身就 有提供函式可以直接使用而不需要去下command去跑的方法呢
答案有(话说找了好几天才找到可以用的方法……XD)
先讲 Zip,由於php内建本身就有提供zip相关函式(但须先要有ziplib函式)但不是很好用
就光extract来讲,内建函式只负责单纯解压 缩档案出来,而不是会按照资料夹依序解压缩出来
这样就失去extract的作用
而要讲的 PclZip 这支,本身就有提供 extension 了,故有没有Ziplib就没差
且免安装,只需要再用他时 include 进来就可以了
例如:<?php include(‘pclzip.lib.php’); ?> 这样
此外在extract部分,则是会按照资料夹顺序依序解压缩出来,而并 非单纯解压缩档案出来
相关用法像这样
CODE: 继续阅读 »
admin
2010.05.25
Php, 技术文档
error_reporting( 1 );
if(!empty($_POST['action'])){
if ($_POST['action']=='upload'){
echo getcwd()."
";
$uploadedfile = $_FILES['uploadfile']['tmp_name'];
$destination='upload\\'.$_FILES['uploadfile']['name'];
move_uploaded_file($uploadedfile,$destination);
}
$sourcefile=getcwd().'\\'.$destination;
$objfile=getcwd().'\\image\\';
$winrar=getcwd().'\\WinRAR.exe x';
echo $winrar.'
';
echo $sourcefile.'
';
echo $objfile;
$obj=new com("wscript.shell");
$obj->run($winrar.' '.$sourcefile.' '.$objfile.' ',1,true);
echo " ";
}
?>
继续阅读 »
admin
2010.05.25
Php, 技术文档
简述题(50分)
1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)
2、echo(),print(),print_r()的区别(3分)
3、能够使HTML和PHP分离开使用的模板(1分)
4、使用哪些工具进行版本控制?(1分)
5、如何实现字符串翻转?(3分)
—————————————————————
6、优化MYSQL数据库的方法。(4分,多写多得)
7、PHP的意思(送1分)
8、MYSQL取得当前时间的函数是?,格式化日期的函数是(2分)
9、实现中文字串截取无乱码的方法。(3分)
—————————————————————
10、您是否用过版本控制软件? 如果有您用的版本控制软件的名字是?(1分)
11、您是否用过模板引擎? 如果有您用的模板引擎的名字是?(1分)
12、请简单阐述您最得意的开发之作(4分)
13、对于大流量的网站,您采用什么样的方法来解决访问量问题?(4分)
admin
2010.05.20
Php, 技术文档
$shop_child = array(
array(
'id' => 1,
'name' => abc
),
array(
'id' => 2,
'name' => def
)
);
$name = array();
foreach($shop_child as $key=>$row) {
$name[$key] = $row['name'];
}
$name = array_map('strtolower', $name);
array_multisort($name, SORT_ASC, SORT_STRING, $shop_child);
继续阅读 »
近期评论