kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

window.onload与 ready以及load的区别

https://www.cnblogs.com/ouber23/articles/4763011.html

页面加载完成有两种事件,

一是ready,表示文档结构已经加载完成(不包含图片等非文字媒体文件),

二是onload,指示页 面包含图片等文件在内的所有元素都加载完成。(可以说:ready 在onload 前加载!!!)

我的理解: 一般样式控制的,比如图片大小控制放在onload 里面加载;

而:jS事件触发的方法,可以在ready 里面加载;

用jQ的人很多人都是这么开始写脚本的:

1
2
3
$(function(){
	// do something
});

其实这个就是jq ready()的简写,他等价于:

1
2
3
$(document).ready(function(){
	//do something
})

或者下面这个方法,jQuer的默认参数是:'document';

1
2
3
$().ready(function(){
	//do something
})

php如何让数组倒叙

https://www.php.cn/faq/521537.html

array_reverse() 函数的基本使用方法

1
array array_reverse ( array $array , bool $preserve_keys = FALSE )

其中,$array 参数是要反转的数组,$preserve_keys 参数如果设置为 true,则会保留数组原始的键值。如果设置为 false 或者不设置,则将重置数组的键值。

PHP ZipArchive::setCompressionName压缩质量

在添加文件之前,我们可以通过设置ZipArchive类的属性setCompressionName来设置文件的压缩质量。

压缩质量有几个选项可供选择,包括

ZipArchive::CM_STORE表示不进行压缩,

ZipArchive::CM_DEFLATE表示使用DEFLATE算法进行压缩。

默认情况下,压缩质量是ZipArchive::CM_STORE,即不进行压缩。

https://www.php.net/manual/en/ziparchive.setcompressionname.php

1
2
3
4
5
6
7
8
9
10
public ZipArchive::setCompressionName(string $name, int $method, int $compflags = 0): bool

name
	Name of the entry.
method
	The compression method, one of the ZipArchive::CM_* constants.
compflags
	Compression level.

Returns true on success or false on failure. 

The compression level (compflags) option is, generally speaking, an integer value between 0 and 9. The behavior of the system depends on the selected method and the value of compflags and can sometimes be not you expected.

The result below is from PHP 8.1 on Windows platform and may possibly be different on other systems or versions:

  • for the CM_DEFAULT method, always CM_DEFLATE is used with level 9, regardless of what you put as compflags,

  • for the CM_STORE method, for compflags 0-9 you get the same result, which is obvious because the method itself means “no compression at all”. However, for compflags>9, surprisingly the CM_DEFLATE method is used instead with compression level 9.

  • for CM_DEFLATE method, 1 means the fastest and weakest compression, while 9 - the slowest and strongest one. compflags=0 and compflags>9 works as it if were with compflags=9,

  • for CM_BZIP2 method, 1 means the fastest and weakest compression, while 9 - the slowest and strongest one. compflags=0 works like compflag=9, and if you use compflags>9, the method will surprisingly switch to CM_DEFLATE level 9,

  • for CM_XZ method, 0 means the fastest and weakest compression, while 9 - the slowest and strongest one. For compflags>9 the method surprisingly switch to CM_DEFLATE level 9.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res === TRUE) {
	$zip->addFromString('foo', 'Some text');
	$zip->addFromString('bar', 'Some other text');
	$zip->addFromString('baa', 'Some other text2');
	$zip->setCompressionName('foo', ZipArchive::CM_STORE);

	$zip->setCompressionName('bar', ZipArchive::CM_DEFLATE);
	$zip->setCompressionName('baa', ZipArchive::CM_DEFLATE, 1);

	$zip->close();
	echo 'ok';
} else {
	echo 'failed';
}
?>

https://www.php.cn/faq/581904.html

1
2
$zip->addFile('path/to/file.txt', 'file.txt');
$zip->setCompressionName('file.txt', ZipArchive::CM_DEFLATE);

除了设置整个压缩文件的压缩质量,我们还可以为单独的文件设置压缩质量,代码示例如下:

1
$zip->setCompressionIndex(0, ZipArchive::CM_DEFLATE);

最后,我们需要关闭ZipArchive对象以完成整个压缩过程:

1
$zip->close();

https://www.cnblogs.com/aipiaoborensheng/p/6362858.html

https://vimsky.com/examples/detail/php-ex---ZipArchive-setCompressionName.html