php 读取MAC地址
class GetMacAddr{
var $return_array = array(); // 返回带有MAC地址的字串数组
var $mac_addr;
function GetMacAddr($os_type){
switch ( strtolower($os_type) ){
case "linux":
$this->forLinux();
break;
case "solaris":
break;
case "unix":
break;
case "aix":
break;
default:
$this->forWindows();
break;
}
$temp_array = array();
foreach ( $this->return_array as $value ){
if (
preg_match("/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i",$value,
$temp_array ) ){
$this->mac_addr = $temp_array[0];
break;
}
}
unset($temp_array);
return $this->mac_addr;
}
function forWindows(){
@exec("ipconfig /all", $this->return_array);
if ( $this->return_array )
return $this->return_array;
else{
$ipconfig = $_SERVER["WINDIR"]."system32ipconfig.exe";
if ( is_file($ipconfig) )
@exec($ipconfig." /all", $this->return_array);
else
@exec($_SERVER["WINDIR"]."systemipconfig.exe /all", $this->return_array);
return $this->return_array;
}
}
function forLinux(){
@exec("ifconfig -a", $this->return_array);
return $this->return_array;
}
}
//方法使用
//$mac = new GetMacAddr(PHP_OS);
//echo $mac->mac_addr;
定义和用法
该过滤器验证FILTER_VALIDATE_IP价值作为一个网址。
名称: “ validate_ip ”
身份证号码: 275
可能的旗帜:
<?php $ip = "192.168.0.1";
if(!filter_var($ip, FILTER_VALIDATE_IP)) { echo "IP is not valid"; } else { echo "IP is valid"; } ?>
输出结果。
is is valid
PHP and AJAX Suggest
这个suggest是仿google的效果了,google总是走在世界的技术的前面啊,下面我们也来看看实例吧.
先看看html文件.
<form> First Name: <input type="text" id="txt1" onkeyup="showHint(this.value)"> </form>
<p>Suggestions: <span id="txtHint"></span></p>
下面用js文件的ajax文件来处理数据.
var xmlHttp; function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="gethint.php"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } }function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }这个文件只是返回php处理的数据,而我们的php文件如下.<?php // Fill up array with names $a[]="Anna"; $a[]="Brittany"; $a[]="Cinderella"; $a[]="Diana"; $a[]="Eva"; $a[]="Fiona"; $a[]="Gunda"; $a[]="Hege"; $a[]="Inga"; $a[]="Johanna"; $a[]="Kitty"; $a[]="Linda"; $a[]="Nina"; $a[]="Ophelia"; $a[]="Petunia"; $a[]="Amanda"; $a[]="Raquel"; $a[]="Cindy"; $a[]="Doris"; $a[]="Eve"; $a[]="Evita"; $a[]="Sunniva"; $a[]="Tove"; $a[]="Unni"; $a[]="Violet"; $a[]="Liza"; $a[]="Elizabeth"; $a[]="Ellen"; $a[]="Wenche"; $a[]="Vicky";//get the q parameter from URL $q=$_GET["q"];//lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint." , ".$a[$i]; } } } } //Set output to "no suggestion" if no hint were found //or to the correct values if ($hint == "") { $response="no suggestion"; } else { $response=$hint; } //output the response echo $response; ?>好了我们的确suggest效果就完成了.
PHP FTP 函数使用教程
该功能提供的FTP客户端访问文件服务器通过文件传输协议( FTP ) 。
该FTP函数是用来打开,登录名和密切的联系,以及上传,下载,重命名,删除和获取信息的文件从文件服务器。并不是所有的FTP功能将与每一个服务器或返回同样的结果。该FTP函数成为可与PHP 3 。
这些功能都是为了详细访问FTP服务器。如果你只希望阅读或写入文件在FTP服务器上,可以考虑使用包装的ftp://与文件的功能。
安装
PHP的Windows版本内置了支持的FTP延长。因此, FTP函数将自动工作。
然而,如果您运行的是Linux版本的PHP中,你将不得不与编译PHP -启用-的F TP( P HP4中+ )或- wi th-的F T P(P H P3中)得到的F T P职能工作。
PHP的FTP函数
PHP的:显示最早的PHP版本,支持的功能。
Function | Description | PHP |
---|---|---|
ftp_alloc() | Allocates space for a file to be uploaded to the FTP server | 5 |
ftp_cdup() | Changes the current directory to the parent directory on the FTP server | 3 |
ftp_chdir() | Changes the current directory on the FTP server | 3 |
ftp_chmod() | Sets permissions on a file via FTP | 5 |
ftp_close() | Closes an FTP connection | 4 |
ftp_connect() | Opens an FTP connection | 3 |
ftp_delete() | Deletes a file on the FTP server | 3 |
ftp_exec() | Executes a program/command on the FTP server | 4 |
ftp_fget() | Downloads a file from the FTP server and saves it to an open file | 3 |
ftp_fput() | Uploads from an open file and saves it to a file on the FTP server | 3 |
ftp_get_option() | Returns runtime behaviors of the FTP connection | 4 |
ftp_get() | Downloads a file from the FTP server | 3 |
ftp_login() | Logs on to an FTP connection | 3 |
ftp_mdtm() | Returns the last modified time of a specified file | 3 |
ftp_mkdir() | Creates a new directory on the FTP server | 3 |
ftp_nb_continue() | Continues retrieving/sending a file (non-blocking) | 4 |
ftp_nb_fget() | Downloads a file from the FTP server and saves it to an open file (non-blocking) | 4 |
ftp_nb_fput() | Uploads from an open file and saves it to a file on the FTP server (non-blocking) | 4 |
ftp_nb_get() | Downloads a file from the FTP server (non-blocking) | 4 |
ftp_nb_put() | Uploads a file to the FTP server (non-blocking) | 4 |
ftp_nlist() | Lists the files in a specified directory on the FTP server | 3 |
ftp_pasv() | Turns passive mode on or off | 3 |
ftp_put() | Uploads a file to the FTP server | 3 |
ftp_pwd() | Returns the current directory name | 3 |
ftp_quit() | Alias of ftp_close() | 3 |
ftp_raw() | Sends a raw command to the FTP server | 5 |
ftp_rawlist() | Returns a detailed list of files in the specified directory | 3 |
ftp_rename() | Renames a file or directory on the FTP server | 3 |
ftp_rmdir() | Removes a directory on the FTP server | 3 |
ftp_set_option() | Sets runtime options for the FTP connection | 4 |
ftp_site() | Sends a SITE command to the server | 3 |
ftp_size() | Returns the size of the specified file | 3 |
ftp_ssl_connect() | Opens a secure SSL-FTP connection | 4 |
ftp_systype() | Returns the system type identifier of the FTP server | 3 |
PHP FTP Constants
PHP: indicates the earliest version of PHP that supports the constant.
Constant | Description | PHP |
---|---|---|
FTP_ASCII | 3 | |
FTP_TEXT | 3 | |
FTP_BINARY | 3 | |
FTP_IMAGE | 3 | |
FTP_TIMEOUT_SEC | 3 | |
FTP_AUTOSEEK | 4 | |
FTP_AUTORESUME | Determine resume position and start position for get and put requests automatically | 4 |
FTP_FAILED | Asynchronous transfer has failed | 4 |
FTP_FINISHED | Asynchronous transfer has finished | 4 |
FTP_MOREDATA | Asynchronous transfer is still active | 4 |
PHP的zip 使用方法
在Zip文件功能可以让你阅读ZIP文件。
-------------------------------------------------- ------------------------------
安装
对于Zip文件的职能工作,您的服务器,这些图书馆必须安装:
该ZZIPlib库吉Draheim :下载ZZIPlib图书馆
邮编PELC的延伸:下载的Zip PELC延长
安装Linux系统
PHP的5 + :邮政编码职能和邮编图书馆默认情况下不启用的,必须从上面的联系。使用-w ith-拉链=方向配置选项,包括邮政编码的支持。
Windows系统下的安装
PHP的5 + :邮政编码职能默认情况下不启用,所以php_zip.dll和ZZIPlib图书馆必须从上面的连结。 php_zip.dll必须启用内部的php.ini 。
为了使任何PHP扩展, PHP的extension_dir设置(在php.ini文件)应设置的目录下的PHP扩展库的位置。例如extension_dir值是c : PHP的分机。
-------------------------------------------------- ------------------------------
PHP的Zip文件功能
PHP的:显示最早的PHP版本,支持的功能。
Function | Description | PHP |
---|---|---|
zip_close() | Closes a ZIP file | 4 |
zip_entry_close() | Closes an entry in the ZIP file | 4 |
zip_entry_compressedsize() | Returns the compressed size of an entry in the ZIP file | 4 |
zip_entry_compressionmethod() | Returns the compression method of an entry in the ZIP file | 4 |
zip_entry_filesize() | Returns the actual file size of an entry in the ZIP file | 4 |
zip_entry_name() | Returns the name of an entry in the ZIP file | 4 |
zip_entry_open() | Opens an entry in the ZIP file for reading | 4 |
zip_entry_read() | Reads from an open entry in the ZIP file | 4 |
zip_open() | Opens a ZIP file | 4 |
zip_read() | Reads the next entry in a ZIP file | 4 |
相关文章
- 这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
- 这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
- PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
- 在php中解析xml文档用专门的函数domdocument来处理,把json在php中也有相关的处理函数,我们要把数据xml 数据存到一个数据再用json_encode直接换成json数据就OK了。...2016-11-25
- index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
PHP中func_get_args(),func_get_arg(),func_num_args()的区别
复制代码 代码如下:<?php function jb51(){ print_r(func_get_args()); echo "<br>"; echo func_get_arg(1); echo "<br>"; echo func_num_args(); } jb51("www","j...2013-10-04- 这篇文章主要介绍了c# 如何对CSV文件操作,帮助大家更好的理解和学习C#,感兴趣的朋友可以了解下...2020-11-03
- 这篇文章主要介绍了PHP编程 SSO详细介绍及简单实例的相关资料,这里介绍了三种模式跨子域单点登陆、完全跨单点域登陆、站群共享身份认证,需要的朋友可以参考下...2017-01-25
- 本文主要介绍了python读取和保存mat文件的方法,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-08-25
- c#获取本机的IP地址的代码,需要的朋友可以参考一下...2020-06-25
- 这篇文章主要介绍了PHP实现创建以太坊钱包转账等功能,对以太坊感兴趣的同学,可以参考下...2021-04-20
- 这篇文章主要为大家详细介绍了微信小程序实现选择地址省市区三级联动,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-06-21
- 首先如果要在程序中使用sdcard进行存储,我们必须要在AndroidManifset.xml文件进行下面的权限设置: 在AndroidManifest.xml中加入访问SDCard的权限如下: <!--...2016-09-20
- 这篇文章主要为大家详细介绍了php微信公众账号开发之五个坑,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2016-10-02
ThinkPHP使用心得分享-ThinkPHP + Ajax 实现2级联动下拉菜单
首先是数据库的设计。分类表叫cate.我做的是分类数据的二级联动,数据需要的字段有:id,name(中文名),pid(父id). 父id的设置: 若数据没有上一级,则父id为0,若有上级,则父id为上一级的id。数据库有内容后,就可以开始写代码,进...2014-05-31- 这篇文章主要介绍了PHP如何通过date() 函数格式化显示时间,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-11-13
- 今天我给大家分享的是在不刷新页面的前提下,使用PHP+jQuery+Ajax实现多图片上传的效果。用户只需要点击选择要上传的图片,然后图片自动上传到服务器上并展示在页面上。...2015-03-15
- 这篇文章主要介绍了golang与php实现计算两个经纬度之间距离的方法,结合实例形式对比分析了Go语言与php进行经纬度计算的相关数学运算技巧,需要的朋友可以参考下...2016-07-29
- 这篇文章主要介绍了C#实现获取MAC地址的方法,很实用的功能,需要的朋友可以参考下...2020-06-25
- perl CPAN中有一个Tie-File 模块极大方便了对大文件的操作...2020-06-29