王新阳

wangxinyang

CSS控制打印时内容

在CSS代码中加入以下内容即可:
@media print{
	/*以下为打印时载入的CSS代码*/
	.banner, .sidebar{display:none;}
	#wrapper, .main{clear:both;width:100% !important;height:auto !important;}
}

CSS3 线性渐变(linear-gradient),半透明+渐变

不兼容IE浏览器,所以IE中要添加默认的background或background-color
1、开始于center(水平方向)和top(垂直方向)也就是Top → Bottom:
/* Firefox 3.6+ */
background-image:-moz-linear-gradient(top, #ace, #f96);
/* Safari 5.1+, Chrome 10+ */
background-image:-webkit-linear-gradient(top, #ace, #f96);
/* Opera 11.10+ */
background-image:-o-linear-gradient(top, #ace, #f96);

2、始于left(水平方向)和center(垂直方向)也是就Left → Right:
/* Firefox 3.6+ */
background-image: -moz-linear-gradient(left, #ace, #f96);
/* Safari 5.1+, Chrome 10+ */
background-image: -webkit-linear-gradient(left, #ace, #f96);
/* Opera 11.10+ */
background-image: -o-linear-gradient(left, #ace, #f96);

3、起始于left(水平方向)和top(垂直方向):
background-image: -moz-linear-gradient(left top, #ace, #f96);
background-image: -webkit-linear-gradient(left top, #ace, #f96);
background-image: -o-linear-gradient(left top, #ace, #f96);

4、角度(Angle):
.deg45 {
	background-image: -moz-linear-gradient(45deg, #ace, #f96);
	background-image: -webkit-linear-gradient(45deg, #ace, #f96);
	background-image: -o-linear-gradient(45deg, #ace, #f96);
}
5、变透明+渐变
div{
    background-image:linear-gradient(
        to bottom
        rgba(0,0,0,.6) 0%,
        rgba(0,0,0,.3) 50%,
        rgba(0,0,0,0) 100%
    );
    background-image:-webkit-linear-gradient(
        bottom,
        rgba(0,0,0,.6) 0%,
        rgba(0,0,0,.3) 50%,
        rgba(0,0,0,0) 100%
    );
}
        rgba(0,0,0,0) 50%
        rgba(0,0,0,0) 50%
        rgba(0,0,0,.6) 0%,

菲涅尔透镜

jq获取iframe加载完后的数据并格式化

$('#iframe').load(function(){
var txt=$($(this)[0].contentWindow.document.body).text(), flag=true;
try{
txt=eval('('+txt+')');
}catch(e){
flag=false;
}
json=flag ? txt : false;
});

身份证号码验证

function idCardValid(idcard) {
var card=idcard;
//是否为空
if(card === '') {
return false;
}
//校验长度,类型
if(/(^\d{15}$)|(^\d{17}(\d|X)$)/i.test(card) === false) {
return false;
}
var arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'], cardTemp=0, i=0; 
//15位升18位
if(card.length==15){
card = card.substr(0, 6) + '19' + card.substr(6);
for(i = 0; i < 17; i ++) { 
cardTemp += card.substr(i, 1) * arrInt[i]; 

card += arrCh[cardTemp % 11]; 
}


//省份验证
var vcity = {
11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",
21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",
33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",
41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",
46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",
54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",
65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"
};
if(vcity[card.substr(0,2)] == undefined) {
return false;
}
//校验生日
var arr=[card.substr(6,4), card.substr(10,2), card.substr(12,2)];
arr.push(new Date(arr.join('-')));
arr.push(new Date().getFullYear());
if(arr[3].getFullYear()==arr[0] && (arr[3].getMonth()+1)==arr[1] && arr[3].getDate()==arr[2]){
//年龄0-120岁
if(arr[4]-arr[0]<0 || arr[4]-arr[0]>120){
return false;
}
}else{
return false;
}
if(idcard.length==15)return true;
for(i = 0; i < 17; i ++) { 
cardTemp += card.substr(i, 1) * arrInt[i]; 

return arrCh[cardTemp % 11]  == card.substr(17, 1)
};

好久不见-WXL

请输入查看密码:

PHP函数用法

1、string number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," )
  本函数可以接受1个、2个或者4个参数(注意:不能是3个):


2、int strtotime(string $time [, int $now = time() ])
  时间运算

<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day 2010-01-01 12:20:25"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>

3、
file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int$maxlen ]]]] ) : string
把文件读入一个字符串。将在参数 offset 所指定的位置开始读取长度为 maxlen 的内容。如果失败,file_get_contents() 将返回 FALSE。
file_get_contents() 函数是用来将文件的内容读入到一个字符串中的首选方法。
如果操作系统支持还会使用内存映射技术来增强性能。如果要打开有特殊字符的 URL (比如说有空格),就需要使用 urlencode() 进行 URL 编码。

设置 file_get_contents() 的超时时间:

//设置超时参数
$opts=array(
        "http"=>array(
                "method"=>"GET",
                "timeout"=>3
                ),
        );
////创建数据流上下文
$context = stream_context_create($opts);
//$url请求的地址,例如:
$result =file_get_contents($url, false, $context);
//伪造header,可用于fopen/file_get_contents
//个别网站伪造referer反而打不开图片,如 https://mmbiz.qlogo.cn/mmbiz_jpg/lpbWiblialBFNfHKQM7hLhCW2f4QwVYHGhxxHa6ZHjS6IcAd0yBG9FpX4qINm2bJ7AhQdyQbibQIQ6juCUcfLiaZMA/0?wx_fmt=jpeg
$opts = array(
	'http' => array(
		'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36\r\n".
			Referer: ".($source_parse_url['scheme'].'://'.$source_parse_url['host'].$source_parse_url['path'])."\r\n",
	),
);
$context = stream_context_create($opts);
$result =file_get_contents($url, false, $context);

更多参考: https://www.cnblogs.com/Renyi-Fan/p/9642301.html

4、iconv ( string $in_charset , string $out_charset , string $str ) 把字符串按要求的字符编码来转换
如果你在 out_charset 后添加了字符串 //TRANSLIT,将启用转写(transliteration)功能。这个意思是,当一个字符不能被目标字符集所表示时,它可以通过一个或多个形似的字符来近似表达。 如果你添加了字符串 //IGNORE,不能以目标字符集表达的字符将被默默丢弃。 否则,会导致一个 E_NOTICE并返回 FALSE。

iconv("utf-8","gbk//TRANSLIT",$str); //utf-8转gbk
iconv("utf-8","gbk//IGNORE",$str);
iconv("utf-8","gbk",$str);
iconv("gbk","utf-8",$str); //gbk转utf-8


CI知识汇总

1、程序执行时间
  在视图中用 echo $this->benchmark->elapsed_time(); 或 {elapsed_time}

2、显示内存消耗
  在视图中用 echo $this->benchmark->memory_usage(); 或 {memory_usage}

3、

CI初始化设置

1、application/config/config.php
a、添加时区设置 date_default_timezone_set('Etc/GMT-8');
b、$config['base_url'] 
c、$config['subclass_prefix'] 扩展类、扩展辅助函数等的前缀

2、application/config/database.php 设置数据库信息
a、配置交换表前缀
$db['default']['dbprefix'] = 'blog_'; 数据库表前缀
$db['default']['swap_pre'] = 'my_'; 交换前缀
这样我们在写sql语句时就用my_这个表前缀,ci会自动把my_换位blog_,这两项可以相同或不设置。

Codeigniter多目录配置网站前台后台的方法

形如以下:
网站前台URL:http://www.aaa.com
网站后台管理URL::http://www.aaa.com/admin

CI源码下载解压后文件结构如下图:

为了达成多目录共享一个CodeIgniter的目标,我们要完成以下步骤:
1、 在application目录下新建子目录admin,至少将上图中红框标注的5个文件夹复制到admin下(其他按需)。这五个文件夹的的作用简单描述一下,详细说明可参考CI官网:
2、设置入口文件。因为根目录下的index.php默认是去找applcation下的controllers下的控制器,为了读取 applcation/admin/controllers下的控制器,我们需要在网站根目录下新建admin文件,并将根目录下的index.php复 制至此,接下来编辑此index.php,找到:
$system_path = "system";   //改为 $system_path = "../system";
$application_folder="application";  //改为 $application_folder = "../application/admin";
另外此目录可能用到的css/js/images 文件夹 也可以放在新建的admin之下。

此时的程序目录结构如下:

这样就可以实现网站前后台的独立访问:
前台地址:http://www.aaa.com/
后台地址:http://www.aaa.com/admin/

CI官方指导方法:http://codeigniter.org.cn/user_guide/general/managing_apps.html

2024-05-17 星期五 农历四月初十