Category: Coding
PHP常用函数
一些常用的PHP函数 function GetIP() { //获取IP if ($_SERVER[“HTTP_X_FORWARDED_FOR”]) $ip = $_SERVER[“HTTP_X_FORWARDED_FOR”]; else if ($_SERVER[“HTTP_CLIENT_IP”]) $ip = $_SERVER[“HTTP_CLIENT_IP”]; else if ($_SERVER[“REMOTE_ADDR”]) $ip = $_SERVER[“REMOTE_ADDR”]; else if (getenv(“HTTP_X_FORWARDED_FOR”)) $ip = getenv(“HTTP_X_FORWARDED_FOR”); else if (getenv(“HTTP_CLIENT_IP”)) $ip = getenv(“HTTP_CLIENT_IP”); else if (getenv(“REMOTE_ADDR”)) $ip = getenv(“REMOTE_ADDR”); else $ip = “Unknown”; return $ip; }
Thinkphp 内置字符串截取函数
ThinkPHP有一个内置字符截取函数msubstr()如下: msubstr($str, $start=0, $length, $charset=”utf-8″, $suffix=true) $str:要截取的字符串
推广你的网站——各大搜索引擎登陆地址大搜捕
推广你的网站——各大搜索引擎登陆地址大搜捕!! http://www.google.com/addurl/?hl=zh-CN&continue=/addurl 谷歌网站登录 http://www.baidu.com/search/url_submit.html 百度网站登录
GooglePreview —- Firefox 附加组件
用firefox 打开 https://addons.mozilla.org/zh-CN/firefox/addon/189 直接安装 安装后 google 中英文收缩 和 yahoo 英文搜索的结果前面都会有个该网站的近期截图和网站的人气排名 图像尺寸 111px × 82px 右击图片查看属性可以看到图片地址,我想这个获取可以用到其他地方。
Google和百度站内搜索代码
<!–Google站内搜索开始–> <form method=get action=”http://www.google.com/search”> <input type=text name=q> <input type=submit name=btnG value=”Google 搜索”> <input type=hidden name=ie value=utf-8> <input type=hidden name=oe value=utf-8> <input type=hidden name=hl value=zh-CN> <input type=hidden name=domains value=”yaoyingying.com”> <input type=hidden name=sitesearch value=”yaoyingying.com”> </form> <!–Google站内搜索结束–>
简单日历程序
刚开始学程序设计那会儿写的,拿出来留恋一下。呵呵! <form action=”rili.php” enctype=”application/x-www-form-urlencoded” method=”post”> 月份 <select multiple=”65535″ name=”mon” size=”0″> <option value=”‘.$m.'”>’.$m.'</option> </select> 年份 <?php echo ‘<input size=”5″ name=”year” type=”text” value=”‘.date(Y).'”>’; ?> <input name=”Submit” type=”submit” value=”提交” /> <input name=”Submit2″ type=”reset” value=”重置” /> </form> <?php date_default_timezone_set(‘UTC’);//自动获取当地的时区 $mon=$_POST[‘mon’]; $year=$_POST[‘year’]; $a=mktime(0,0,0,$mon,01,$year); $daynum = date(t,$a);//一共28天 , $firstday=date(w,$a);//第一天是星期4, echo $daynum .” – “; echo $firstday; echo ‘<div style=”border:#FF6600 solid 1px;…
Mysql ALTER TABLE 操作
这里是一个例子,显示了一些ALTER TABLE用法。我们以一个如下创建的表t1开始: mysql> CREATE TABLE t1 (a INTEGER,b CHAR(10));
XAMPP 的 Linux 版 (x86 兼容处理器版)
XAMPP 的 Linux 版 1.7, 2008年 12月 21日 http://jaist.dl.sourceforge.net/sourceforge/xampp/xampp-linux-1.7.tar.gz
How to reset the mySQL admin password
怎么重置MYSQL 的管理员密码 在linux 环境下,重置root 密码主要通过以下几个方面: How to reset the mySQL admin password In a Unix environment, the procedure for resetting the root password is as follows: 1. Log on to your system as either the Unix root user or as the same user that the mysqld server runs as. 2. Locate the .pid file that…
Ubuntu Server apt-get install Apache2 & PHP5 & MySQL5
用apt-get方法安装mysql5 + Apache2 + PHP5+Phpmyadmin: 大家请先看下Ubuntu的WIKI,(http://wiki.ubuntu.org)上面讲的很详细的。但本人按上面做的第一次没有成功。apache2,php5,mysql5都可以运行,就是phpmyadmin不能用。 本人得到的经验是:MYSQL安成功后,一定要先给它设个密码,这上步是不可少的。 此篇只代表个人的观点和经验,可能会片面化和有错误,请大家批评指正,有问题大家一起来讨论!!
PHPlist Error:Database error 1146 Table ‘DBname.user_group’ doesn’t exist
The “Database error 1146 while doing query Table ‘DBname.user_group’ doesn’t exist’ has been reported by several users after installing release 2.10.7 I’m not sure, but since I can’t find any user_group table in the previous version (2.10.5) either, I guess that this table isn’t part of the phplist database itself, but possibly of the Webbler…
Find matching HTML tags (greedy)
参考:http://cn.php.net/preg_match_all 非常有用的正则。 <?php // The \\2 is an example of backreferencing. This tells pcre that // it must match the second set of parentheses in the regular expression // itself, which would be the ([\w]+) in this case. The extra backslash is // required because the string is in double quotes. $html = “<b>bold text</b><a href=howdy.html>click me</a>”; preg_match_all(“/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/”, $html, $matches, PREG_SET_ORDER);foreach ( $matches as $val) { echo “matched: ” . $val[0] . “\n”; echo “part 1: ” . $val[1] . “\n”; echo “part 2: ” . $val[3] . “\n”; echo “part 3: ” . $val[4] . “\n\n”; } ?>
PHP中include()与require()的区别
引用文件的方法有两种:require 及 include。两种方式提供不同的使用弹性。 require 的使用方法如 require(“MyRequireFile.php”); 。这个函数通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require 所指定引入的文件,使它变成 PHP 程序网页的一部份。常用的函数,亦可以这个方法将它引入网页中。 include 使用方法如 include(“MyIncludeFile.php”); 。这个函数一般是放在流程控制的处理部分中。PHP 程序网页在读到 include 的文件时,才将它读进来。这种方式,可以把程序执行时的流程简单化。
php中magic_quotes_gpc的作用
魔术引用发生作用是在传递$_GET,$_POST,$_COOKIE时 1. 条件: magic_quotes_gpc=off 写入数据库的字符串未经过任何过滤处理。从数据库读出的字符串也未作任何处理。 数据: $data=”snow”’’sun” ; (snow和sun之间是四个连续的单引号). 操作: 将字符串:”snow”’’sun” 写入数据库, 结果: 出现sql语句错误,mysql不能顺利完成sql语句,写入数据库失败。 数据库保存格式:无数据。 输出数据格式:无数据。 说明: 对于未经处理的单引号在写入数据库时会使sql语句发生错误。 2. 条件: magic_quotes_gpc=off 写入数据库的字符串经过函数addlashes()处理。从数据库读出的字符串未作任何处理。 数据: $data=”snow”’’sun” ; (snow和sun之间是四个连续的单引号). 操作: 将字符串:”snow”’’sun” 写入数据库, 结果: sql语句顺利执行,数据成功写入数据库 数据库保存格式:snow”’’sun (和输入一样) 输出数据格式:snow”’’sun (和输入一样) 说明: addslashes()函数将单引号转换为\’的转义字符使sql语句成功执行, 但\’并未作为数据存入数据库,数据库保存的是snow”’’sun 而并不是我们想象的snow\’\’\’\’sun 3. 条件: magic_quotes_gpc=on 写入数据库的字符串未经过任何处理。从数据库读出的字符串未作任何处理。 数据: $data=”snow”’’sun” ; (snow和sun之间是四个连续的单引号). 操作: 将字符串:”snow”’’sun” 写入数据库, 结果: sql语句顺利执行,数据成功写入数据库 数据库保存格式:snow”’’sun (和输入一样) 输出数据格式:snow”’’sun…