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

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

📚 291 篇文章 🏷️ 504 个标签 📂 90 个分类

🔥 最新文章

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

Linux下常用文件解压

木木夕
1.以.a为扩展名的文件: #tar xv file.a
2.以.z为扩展名的文件: #uncompress file.Z
3.以.gz为扩展名的文件: #gunzip file.gz
4.以.bz2为扩展名的文件: #bunzip2 file.bz2
5.以.tar.Z为扩展名的文件: #tar xvZf file.tar.Z 或 #compress -dc file.tar.Z | tar xvf
6.以.tar.gz/.tgz为扩展名的文件: #tar xvzf file.tar.gz 或 gzip -dc file.tar.gz | tar xvf -
7.以.tar.bz2为扩展名的文件: #tar xvIf file.tar.bz2 或 bzip2 -dc file.tar.bz2 | xvf –
8.以.cpio.gz/.cgz为扩展名的文件: #gzip -dc file.cgz | cpio -div
9.以.cpio/cpio为扩展名的文件: #cpio -div file.cpio 或cpio -divc file.cpio
10.以.rpm为扩展名的文件安装: #rpm -i file.rpm
11.以.rpm为扩展名的文件解压缩: #rpm2cpio file.rpm | cpio -div
12.以.deb为扩展名的文件安装: #dpkg -i file.deb
13.以.deb为扩展名的文件解压缩: #dpkg-deb —fsys-tarfile file.deb | tar xvf - ar p file.deb data.tar.gz | tar xvzf –
14.以.zip为扩展名的文件: #unzip file.zip
15.在linux下解压Winzip格式的文件: 要是装了jdk的话,可以用jar命令;还可以使用unzip命令。
16.直接解压.tar.gz文件: xxxx.tar.gz文件使用tar带zxvf参数,可以一次解压开。XXXX为文件名。 例如:$tar zxvf xxxx.tar.gz 各种压缩文件的解压(安装方法)
17.文件扩展名解压(安装方法): .a ar xv file.a .Z uncompress file.Z .gz gunzip file.gz .bz2 bunzip2 file.bz2 .tar.Z tar xvZf file.tar.Z compress -dc file.tar.Z | tar xvf - .tar.gz/.tgz tar xvzf file.tar.gz gzip -dc file.tar.gz | tar xvf - .tar.bz2 tar xvIf file.tar.bz2 bzip2 -dc file.tar.bz2 | xvf - .cpio.gz/.cgz gzip -dc file.cgz | cpio -div .cpio/cpio cpio -div file.cpio cpio -divc file.cpio .rpm/install rpm -i file.rpm .rpm/extract rpm2cpio file.rpm | cpio -div .deb/install dpkg -i file.deb .deb/exrtact dpkg-deb —fsys-tarfile file.deb | tar xvf - ar p file.deb data.tar.gz | tar xvzf - .zip unzip file.zip bzip2 -d myfile.tar.bz2 | tar xvf

18.tar xvfz myfile.tar.bz2 x 是解压 v 是复杂输出 f 是指定文件 z gz格式
19.gzip gzip[选项]要压缩(或解压缩)的文件名 -c将输出写到标准输出上,并保留原有文件。 -d将压缩文件压缩。 -l对每个压缩文件,显示下列字段:压缩文件的大小,未压缩文件的大小、压缩比、未压缩文件的名字 -r递归式地查找指定目录并压缩或压缩其中的所有文件。 -t测试压缩文件是正完整。 -v对每一个压缩和解压缩的文件,显示其文件名和压缩比。 -num-用指定的数字调整压缩的速度。
20.举例: 把/usr目录并包括它的子目录在内的全部文件做一备份,备份文件名为usr.tar tar cvf usr.tar /home 把/usr 目录并包括它的子目录在内的全部文件做一备份并进行压缩,备份文件名是usr.tar.gz tar czvf usr.tar.gz /usr 压缩一组文件,文件的后缀为tar.gz #tar cvf back.tar /back/ #gzip -q back.tar or #tar cvfz back.tar.gz /back/ 释放一个后缀为tar.gz的文件。 #tar zxvf back.tar.gz #gzip back.tar.gz #tar xvf back.tar

Common File Extraction Commands on Linux

木木夕
1. Files with the .a extension: #tar xv file.a
2. Files with the .z extension: #uncompress file.Z
3. Files with the .gz extension: #gunzip file.gz
4. Files with the .bz2 extension: #bunzip2 file.bz2
5. Files with the .tar.Z extension: #tar xvZf file.tar.Z or #compress -dc file.tar.Z | tar xvf
6. Files with the .tar.gz/.tgz extension: #tar xvzf file.tar.gz or gzip -dc file.tar.gz | tar xvf -
7. Files with the .tar.bz2 extension: #tar xvIf file.tar.bz2 or bzip2 -dc file.tar.bz2 | xvf –
8. Files with the .cpio.gz/.cgz extension: #gzip -dc file.cgz | cpio -div
9. Files with the .cpio/cpio extension: #cpio -div file.cpio or cpio -divc file.cpio
10. Installing files with the .rpm extension: #rpm -i file.rpm
11. Extracting files with the .rpm extension: #rpm2cpio file.rpm | cpio -div
12. Installing files with the .deb extension: #dpkg -i file.deb
13. Extracting files with the .deb extension: #dpkg-deb —fsys-tarfile file.deb | tar xvf - ar p file.deb data.tar.gz | tar xvzf –
14. Files with the .zip extension: #unzip file.zip
15. Extracting Winzip-format files under Linux: if you have the JDK installed you can use the jar command; the unzip command works too.
16. Extracting a .tar.gz file directly: for an xxxx.tar.gz file, use tar with the zxvf options and it will unpack in one go. XXXX is the file name. For example: $tar zxvf xxxx.tar.gz Extraction (and install methods) for all kinds of compressed files
17. Extraction by file extension (install methods): .a ar xv file.a .Z uncompress file.Z .gz gunzip file.gz .bz2 bunzip2 file.bz2 .tar.Z tar xvZf file.tar.Z compress -dc file.tar.Z | tar xvf - .tar.gz/.tgz tar xvzf file.tar.gz gzip -dc file.tar.gz | tar xvf - .tar.bz2 tar xvIf file.tar.bz2 bzip2 -dc file.tar.bz2 | xvf - .cpio.gz/.cgz gzip -dc file.cgz | cpio -div .cpio/cpio cpio -div file.cpio cpio -divc file.cpio .rpm/install rpm -i file.rpm .rpm/extract rpm2cpio file.rpm | cpio -div .deb/install dpkg -i file.deb .deb/exrtact dpkg-deb —fsys-tarfile file.deb | tar xvf - ar p file.deb data.tar.gz | tar xvzf - .zip unzip file.zip bzip2 -d myfile.tar.bz2 | tar xvf

18.tar xvfz myfile.tar.bz2 x is for extract, v is verbose output, f specifies the file, z is the gz format
19.gzip gzip[options]the name of the file to compress (or decompress) -c writes the output to standard output and keeps the original file. -d decompresses the compressed file. -l for each compressed file, displays the following fields: the size of the compressed file, the size of the uncompressed file, the compression ratio, and the name of the uncompressed file -r recursively searches the specified directory and compresses or decompresses all the files in it. -t tests whether the compressed file is intact. -v for each file compressed or decompressed, displays its filename and compression ratio. -num- adjusts the compression speed with the specified number.
20. Examples: back up every file in the /usr directory, including its subdirectories, with the backup file named usr.tar tar cvf usr.tar /home back up every file in the /usr directory, including its subdirectories, and compress it, with the backup file named usr.tar.gz tar czvf usr.tar.gz /usr compress a group of files, with the suffix tar.gz #tar cvf back.tar /back/ #gzip -q back.tar or #tar cvfz back.tar.gz /back/ unpack a file with the tar.gz suffix. #tar zxvf back.tar.gz #gzip back.tar.gz #tar xvf back.tar