php网站目录结构
方案1:
root_dir
–config
–include
news.php(基础处理类)
member.php
admin.php
–lib(文件夹内放置smarty的相关文件)
[...]
php 中英混杂字符串截取
<?php
/*
* 中英文字符串的截取
*/
function sysSubStr($String,$Length,$Append = false)
{
if (strlen($String) <= $Length ) {
return $String;
}
else
{
$I = 0;
while ($I < $Length)
{
$StringTMP = substr($String,$I,1);
if ( ord($StringTMP) >=224 )
{
$StringTMP = substr($String,$I,3);
$I = $I + 3;
}
elseif( ord($StringTMP) >=192 )
{
$StringTMP = substr($String,$I,2);
$I = $I + 2;
}
else
{
$I = $I + 1;
}
$StringLast[] = $StringTMP;
}
$StringLast = implode(””,$StringLast);
if($Append)
{
$StringLast .= “…”;
}
return $StringLast;
}
}
function cut($Str, $Length) //$Str为截取字符串,$Length为需要截取的长度
{
global $s;
$i = 0;
$l = [...]
php 跳转函数
<?php
/*
* 直接返回
* $declaration 返回时的说明
*/
function ErrorBack($declaration)
{
$html = ‘
<html><head><title>提示信息</title>
<meta http-equiv=”content-Type” content=”text/html charset=utf-8″ />
<META HTTP-EQUIV=”pragma” CONTENT=”no-cache”>
<META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache, must-revalidate”>
<base target=”_self”/></head>
<body leftmargin=”0″ topmargin=”0″ bgcolor=”#FFFFFF”><center>
<div style=”border:1px solid #336699;width:550px;margin-top:25px;padding:1px;”>
<div style=”height:20px;font-size:16px;font-weight:bold;BACKGROUND:#1693D9;BORDER-BOTTOM:
#A8ECFF 2px solid;color:#FFFFFF;vertical-align:middle;padding:5px;”>- 提...
php 生成 随机数的函数
<?php
//生成 随机数的函数
function random($length, $numeric = 0) {
PHP_VERSION < ‘4.2.0′ && mt_srand((double)microtime() * 1000000);
if($numeric) {
$hash = sprintf(’%0′.$length.’d’, mt_rand(0, pow(10, $length) - 1));
} else {
$hash = ”;
$chars = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz’;
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
return $hash;
}
echo random(3);
?>
php 阿拉伯数字转换成中文数字
<?php
/**
* @desc 阿拉伯数字转换成中文数字
*/
function num2Chinese($num)
{
static $_Chinese=array(’零’,’一’,’二’,’三’,’四’,’五’,’六’,’七’,’八’,’九’);
static $_List=array(’零’,’十’,’百’,’千’,’万’,’十万’,’百万’,’千万’,’亿’,’十亿’,’百亿’,’千亿’,’万亿’);
$lastLength=strlen($_List[0]);
$lastLength=0-$lastLength;
$num +=0;
$num=explode(’.’,$num);
$num[0]=strrev($num[0]);
$num_length=strlen($num[0]);
$tmpArray=array();
$IF_LAST_ZERO=0;
$tmp=0;
$lastWord=”;
$lastKey=”;
for ($i=0;$i<$num_length;++$i)
{
$tmp=intval($num[0][$i]...
php 加解密函数
<?php
//加解密函数
$encode = authcode(’我要加密’,'ENCODE’,'34577′);
$decode = authcode($encode,’DECODE’,'34577′);
echo $encode."
";
echo $decode;
//$auth_key = 34577 ; //密钥
function authcode($string, $operation, $key = ”)
{
$key = md5($key ? $key : $GLOBALS['auth_key']);
$key_length = strlen($key);
$string = $operation == ‘DECODE’ ? base64_decode($string) : substr(md5($string.$key), 0, 8).$string;
$string_length = strlen($string);
$rndkey = $box = array();
$result = ”;
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($key[$i % $key_length]);
$box[$i] = $i;
}
for($j = $i = 0; [...]
php 数据库操作类
<?php
class DB_Sql
{
/* public: connection parameters */
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
/* public: configuration parameters */
var $Auto_Free = 1; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages.
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $PConnect = 0; [...]
php apache本地能搭建多个站点
本地能搭建多个站点,需要修改 apache/conf/httpd.conf文件 和 Windows/system32/drivers/etc/hosts这2个文件.
1、 用写字本打开httpd.conf这个文件,在下面添加
NameVirtualHost 192.168.1.56
<VirtualHost 192.168.1.56>
DocumentRoot “F:/test”
ServerName www.w.com
</VirtualHost>
2.修改hosts文件在最后加上
127.0.0.1 www.w.com
很有启发的一篇文章 HP大中国总裁写的
这是个浮躁的人们最不喜欢的话题,本来不想说这个话题,因为会引起太多的争论,而我又无意和人争论这些,但是考虑到对于职业生涯的长久规划,这是一个躲避不了的话题,还是决定写一写,不爱看的请离开吧。
并不是每次穿红灯都会被汽车撞,并不是每个罪犯都会被抓到,并不是每个错误都会被惩罚,并不是每个贪官都会被枪毙,并不是你的每一份努力都会得到回报,并不是你的每一次坚持都会有人看到,并不是你每一点付出都能得到公正的回报,并不是你的每一个善意都能被理解……这个,就是世道。好吧,世道不够好,可是,你有推翻世道的勇气么?如果没有,你有更好的解决办法么?有很多时候,人需要一点耐心,一点信心。每个人总会轮到几次不公平的事情,而通常,安心等待是最好的办法。
有很多时候我们需要等待...
