欢迎来到 艾瑞可erik 的魔法世界 🧙‍♂️

给我一个需求,还你一个项目——别管它是什么。这就是全栈。

📚 292 篇文章 🏷️ 507 个标签 📂 90 个分类

🔥 最新文章

访客统计计数器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>访客统计</title>
</head> <body>
<?php
if (!@$fp=fopen("count.txt", "r")){ //以只读的方式打开文件,这步可要可不要根据实际情况来确定。
echo "count.txt文件创建成功!<br />";
}
@$num=fgets($fp,12);//读取11位数字
if ($num=="")$num=0;//如果文件count.txt内容为空,则初始化为0 $num++; //浏览次数加1
@fclose($fp); $fp=fopen("count.txt", "w");//以只读的方式打开文件
fwrite($fp, $num); //写入加1后结果
fclose($fp); //关闭文件 echo "您是第".$num."位浏览者!";
?>
</body>
</html>

Visitor Statistics Counter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>访客统计</title>
</head> <body>
<?php
if (!@$fp=fopen("count.txt", "r")){ //open the file in read-only mode; this step is optional and depends on the actual situation.
echo "count.txt文件创建成功!<br />";
}
@$num=fgets($fp,12);//read 11 digits
if ($num=="")$num=0;//if the content of count.txt is empty, initialize it to 0 $num++; //increment the view count by 1
@fclose($fp); $fp=fopen("count.txt", "w");//open the file in read-only mode
fwrite($fp, $num); //write the result after adding 1
fclose($fp); //close the file echo "您是第".$num."位浏览者!";
?>
</body>
</html>

php面向对象

__construct()构造函数,主要是通过关键字new生成实例的时候,它就会被调用执行。(构造函数不能返回值) __destructor()析构函数,它是在对象被销毁的时候被调用执行的。(对象被销毁时清空资源或者记录日志信息) __get(),__set()访问函数,类属性被访问和操作,访问函数都会被激发。oop思想不鼓励直接从类的外部访问类的属性,所以使用它们可以避免直接对类属性的访问。

Object-oriented PHP

__construct() is the constructor, mainly called and executed when an instance is generated with the new keyword. (A constructor cannot return a value.) __destructor() is the destructor, called and executed when the object is destroyed. (It clears resources or writes log information when the object is destroyed.) __get(), __set() are accessor functions; whenever a class property is accessed or manipulated, the accessor functions are triggered. The oop philosophy discourages accessing class properties directly from outside the class, so using them avoids direct access to class properties.

php时间函数

date_default_timezone_set();设置默认时区时间 strtotime()函数,将任何英文文本的日期时间描述解析为 Unix 时间戳 getdate()函数,把生成的时间戳转化为一个数组,包含各个部分。 checkdate()函数,检查日期的有效性 格式 checkdate(月份,日期,年份) mktime()函数,取得一个日期的时间戳 格式 mktime(小时,分钟,秒,月份,日期,年份) strftime()函数,把时间戳格式化为日期和时间 格式 strftime(格式,时间戳) gmstrftime()函数和strftime()函数用法一致,只是gmstrftime()函数是显示标准的GMT时间 笔者遇到过日期和时间格式符,%Z显示的中文编码为GBK而我主体用的是utf8,所以只能转码用 iconv()函数 格式 iconv(原字符编码,要转换成的字符编码,转换目标) php时间函数

PHP date and time functions

date_default_timezone_set(); sets the default timezone time. The strtotime() function parses any English textual datetime description into a Unix timestamp. The getdate() function turns the generated timestamp into an array containing each part. The checkdate() function checks whether a date is valid, format checkdate(month,day,year). The mktime() function gets the timestamp of a date, format mktime(hour,minute,second,month,day,year). The strftime() function formats a timestamp into a date and time, format strftime(format,timestamp). The gmstrftime() function is used the same way as the strftime() function, except that gmstrftime() displays standard GMT time. I once ran into a date and time format specifier: %Z displayed Chinese encoded as GBK while the rest of my site used utf8, so I could only convert the encoding with the iconv() function, format iconv(original character encoding,character encoding to convert to,conversion target). PHP date and time functions

php开发中数组函数

php开发中数组是经常性的用到 那就介绍一下一维数组中的排序函数 sort()函数,默认排序从低到高排列 asort()函数,根据数组元素的值升序排列 ksort()函数,根据数组元素的键值,也就是关键字的升序排列 rsort()函数正好和sort()函数相反 arsort()函数正好和asort()函数相反 krsort()函数正好和ksort()函数相反 array_unshift()函数,向数组中与添加元素 array_unshift(目标数组,要添加的元素) array_push()函数,向数组中添加元素,以实现先进先出 array_unshift(目标数组,要添加的元素) array_shift()函数,删除目标数组的头一个数组元素 array_shift(目标数组) array_pop()函数,删除目标数组的最后一个数组元素 array_pop(目标数组) array_key_exists()函数专门针对联合数组的‘键名’进行查询 array_search()函数专门针对联合数组的‘元素值’进行查询 array_keys()函数是取得数组‘键值’ array_values()函数是取得数组‘元素值’ count()函数,为统计数组的元素个数 array_count_values()函数,为统计数组的元素值个数(只能用于一维数组) array_unique()函数实现数组中元素的唯一性,也就是去掉数组中重复的元素 array_flip()函数调换数组中的键值和元素值位置,如果有重复的键值则覆盖键值,显示最后一次赋值的键值 serialize()函数,数组序列化 unserialize()函数,数组反序列化

Array functions in PHP development

Arrays are used constantly in PHP development, so let me introduce the sorting functions for one-dimensional arrays: the sort() function, which by default sorts from low to high; the asort() function, which sorts in ascending order by the array element values; the ksort() function, which sorts in ascending order by the array element keys, that is, the keywords; the rsort() function, which is exactly the opposite of the sort() function; the arsort() function, which is exactly the opposite of the asort() function; the krsort() function, which is exactly the opposite of the ksort() function. The array_unshift() function adds an element to the array array_unshift(target array, element to add) The array_push() function adds an element to the array to implement first-in-first-out array_unshift(target array, element to add) The array_shift() function deletes the first array element of the target array array_shift(target array) The array_pop() function deletes the last array element of the target array array_pop(target array) The array_key_exists() function is specifically for querying the ‘key name’ of an associative array The array_search() function is specifically for querying the ‘element value’ of an associative array The array_keys() function retrieves the array ‘keys’ The array_values() function retrieves the array ‘element values’ The count() function counts the number of array elements The array_count_values() function counts how many times each array element value occurs (it can only be used on one-dimensional arrays) The array_unique() function makes the array elements unique, that is, it removes duplicate elements from the array The array_flip() function swaps the positions of the keys and the element values in the array; if there are duplicate keys, the key is overwritten and the value from the last assignment is shown The serialize() function serializes an array The unserialize() function unserializes an array

php中字符串、正则函数

字符串统计

计算字符串长度在php开发中经常遇到,需要使用的函数是strlen() 字符串单词统计函数 str_word_count() (只对ASCII的英文单词起作用)

清除空格

php开发在很多情况下要考虑客户使用便捷,比如输入用户名不小心多了一个空格,怎么办。那就用清楚空格函数 ltrim()函数是从左清除字符串头部的空格 rtrim()函数是从右清除字符串头部的空格 trim()函数是两边同时去除头部和尾部的空格 这三个函数大家可以找一下规律,trim是左右清楚,那么,ltrim中l就好比left左边,所以是左边清除。同理,右边也是。

String and regular expression functions in PHP

String statistics

Calculating string length comes up often in PHP development; the function you need is strlen(). For counting the words in a string there’s str_word_count() (it only works on ASCII English words)

Removing spaces

In many cases PHP development has to take user convenience into account — for example, what if someone accidentally types an extra space when entering their username? Then you use the space-clearing functions: ltrim() removes the spaces at the left end of the string, rtrim() removes the spaces at the right end of the string, and trim() removes the leading and trailing spaces on both sides at the same time. You can look for the pattern in these three functions: trim clears both the left and the right, so in ltrim the l is like left, meaning it clears on the left. Likewise for the right.

php函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php 
$arr\[0\]\[0\]=10;
$arr\[0\]\[1\]=22;
$arr\[1\]\[0\]=1E+05;
$arr\[1\]\[1\]="这不是来了";
for($i=0;$i<count($arr);$i++){
for($k=0;$k<count($arr\[$i\]);$k++){
$arr1=each($arr\[$i\]);
echo "$arr1\[value\]<br />"; } }
//php向函数传递参数
function totalneedtopay($days,$roomprice){
$totalcost=$days*$roomprice;
echo "需要支付的总价:$totalcost"."元<br />";
}
$rentdays=3;
$roomprice=168;
totalneedtopay($rentdays, $roomprice);
totalneedtopay(5,198); //php向函数中传递参数引用
$fee=300; $serviceprice=50; function totalfee(&$fee,$serviceprice){
$fee=$fee+$serviceprice; echo "需要支付的总价:$fee"."元<br />";
}
totalfee($fee, $serviceprice);
totalfee($fee, $serviceprice); //php从函数中返回值
function totalneedtopay1($days1, $roomprice1){
return $days1*$roomprice1;
}
$rentdays1=3; $roomprice1=168;
echo totalneedtopay1($rentdays1, $roomprice1);
?>

PHP Functions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php 
$arr\[0\]\[0\]=10;
$arr\[0\]\[1\]=22;
$arr\[1\]\[0\]=1E+05;
$arr\[1\]\[1\]="这不是来了";
for($i=0;$i<count($arr);$i++){
for($k=0;$k<count($arr\[$i\]);$k++){
$arr1=each($arr\[$i\]);
echo "$arr1\[value\]<br />"; } }
//php passing parameters to a function
function totalneedtopay($days,$roomprice){
$totalcost=$days*$roomprice;
echo "需要支付的总价:$totalcost"."元<br />";
}
$rentdays=3;
$roomprice=168;
totalneedtopay($rentdays, $roomprice);
totalneedtopay(5,198); //php passing parameters by reference into a function
$fee=300; $serviceprice=50; function totalfee(&$fee,$serviceprice){
$fee=$fee+$serviceprice; echo "需要支付的总价:$fee"."元<br />";
}
totalfee($fee, $serviceprice);
totalfee($fee, $serviceprice); //php returning a value from a function
function totalneedtopay1($days1, $roomprice1){
return $days1*$roomprice1;
}
$rentdays1=3; $roomprice1=168;
echo totalneedtopay1($rentdays1, $roomprice1);
?>

ecshop后台管理员登陆显示商品列表价格不同

文件 goods_list.htm privilege.php privilege.php找到set_admin_session($row[‘user_id’], $row[‘user_name’], $row[‘action_list’], $row[‘last_login’]);在其上下分别添加 $admin_zk=explode(“||”,$row[‘adminzk’ ]);上 $_SESSION[‘adminzk’] = $admin_zk[2];下 在查找 if(!empty($ec_salt))把sql预计加上字段adminzk 在goods_list.htm查找 {$goods.shop_price} 把 {$goods.shop_price} 改为{if $goods.shop_price=$goods.shop_price*$smarty.session.adminzk/100} {$goods.shop_price} {/if} 其中折扣adminzk在管理员列表里格式###|###|###|###|###||###||###

ECShop admin shows different prices in the product list after logging in

File goods_list.htm, privilege.php privilege.php — find set_admin_session($row[‘user_id’], $row[‘user_name’], $row[‘action_list’], $row[‘last_login’]); add the following above and below it respectively: $admin_zk=explode(“||”,$row[‘adminzk’ ]); on top, $_SESSION[‘adminzk’] = $admin_zk[2]; below. Then find if(!empty($ec_salt)) and add the field adminzk to the SQL statement. In goods_list.htm find {$goods.shop_price} and change {$goods.shop_price} to {if $goods.shop_price=$goods.shop_price*$smarty.session.adminzk/100} {$goods.shop_price} {/if}. The discount adminzk is stored in the administrator list in the format ###|###|###|###|###||###||###

Hey, What Are You Doing

It’s neither spring nor autumn, and every year is the same sky.

No envy, no greed, only quiet companionship

The mountains are no more, the road is no longer long, and still my face is wordless

With the caress the four seasons give, yet always lingering on and on

Through the hazy little path, I see the edge of the door

In fact, I’m at the edge, and my world is changing.

ecshop后台会员邮箱验证改为管理员可控制验证通过

登陆后管理员查看会员列表会发现邮箱验证这块必须客户验证才有效果,不过大多数客户不愿意去验证,就改为管理员可操作吧 因为邮箱验证时判断客户验证状态0或1来选择显示图片对和错的,也刚好想到,在商品列表里有上架、下架,是否新品……刚好可以吧代码复制过来作参考 从商品列表里获知是js验证传输数据的,直接找到js文件,从中打印一下看看路径。根据路径在会员文件里更改数据 商品列表代码

Making ECShop Backend Member Email Verification Controllable by the Administrator

After logging in, when the administrator looks at the member list they’ll find that the email verification part only works if the customer verifies it themselves, but most customers are unwilling to go and verify, so let’s change it so the administrator can do it. During email verification the customer’s verification status of 0 or 1 is used to decide whether to show the correct or the incorrect image, and it also occurred to me that in the product list there is put on sale, take off sale, whether it’s a new item… so I can just copy that code over as a reference. From the product list I learned that it’s js that validates and transmits the data, so I went straight to the js file and printed something out of it to see the path. Then, following the path, change the data in the member file. Product list code