1、今日除夕,在乡下过年,艳阳高照,合理合法躺平的日子,心安理得享受不内卷的闲暇时光。
2、无论朋友圈,还是科技界,DeepSeek AI 都成了热门话题。我用过几个月的DeepSeek 开放平台的api ,对它的理解不深刻,甚至很肤浅。DeepSeek最近一下子就大火了,按流行的说法就是用500万美元实现了10亿美元的效果。看新闻,就在今天DeepSeek 推出了janus pro 多模态大模型,家里有高配电脑的可以玩起来了。在新闻通稿里,在分析文章里,对DeepSeek不吝溢美之词,堆积着各种我这种低端三流程序员看不懂的AI 术语。看了一上午有关DeepSeek AI 文章,我既高兴,又寂寞。高兴的是终于有咱国产的AI扬眉吐气了,很长脸。寂寞的是,这么高大上的高科技,离我这样三流程序员,还真有点远,我已严重落后了。
对象属性现在可以其 get 和 set 操作中关联相关的附加逻辑。根据用法,这可能会也可能不会使属性变为虚拟属性,即该属性根本没有实际的存储值。
<?php
class Person
{
// “虚拟”属性,可能无法明确设置。
public string $fullName {
get => $this->firstName . ' ' . $this->lastName;
}
// 所有的写入操作都会经过这个挂钩,结果就是写入的内容。
// 读取访问正常。
public string $firstName {
set => ucfirst(strtolower($value));
}
// 所有的写入操作都会经过这个挂钩,它必须写入支持值本身。
// 读取访问正常。
public string $lastName {
set {
if (strlen($value) < 2) {
throw new \InvalidArgumentException('Too short');
}
$this->lastName = $value;
}
}
}
$p = new Person();
$p->firstName = 'peter';
print $p->firstName; // 打印“Peter”
$p->lastName = 'Peterson';
print $p->fullName; // 打印“Peter Peterson”
不对称属性可见性
现在可以将对象属性的 set 可见性和 get 可见性分开控制。
<?php
class Example
{
// 第一个可见性修饰符控制 get 可见性,第二个修饰符控制 set 可见性。
// The get-visibility must not be narrower than set-visibility.
public protected(set) string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}
class PhpVersion
{
#[\Deprecated(
message: "use PhpVersion::getVersion() instead",
since: "8.4",
)]
public function getPhpVersion(): string
{
return $this->getVersion();
}
public function getVersion(): string
{
return '8.4';
}
}
$phpVersion = new PhpVersion();
// Deprecated: Method PhpVersion::getPhpVersion() is deprecated since 8.4, use PhpVersion::getVersion() instead
echo $phpVersion->getPhpVersion();
新的 ext-dom 功能和 HTML5 支持
新的 DOM API 包括符合标准的支持,用于解析 HTML5 文档,修复了 DOM 功能行为中的几个长期存在的规范性错误,并添加了几个函数,使处理文档更加方便。
新的 DOM API 可以在 Dom 命名空间中使用。使用新的 DOM API 可以使用 Dom\HTMLDocument 和 Dom\XMLDocument 类创建文档。
$dom = Dom\HTMLDocument::createFromString(
<<<HTML
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);
$node = $dom->querySelector('main > article:last-child');
var_dump($node->classList->contains("featured")); // bool(true)
最近,我们团队最近对微慕登录插件做了一点完善,加入了“网站应用微信登录”的方式,在pc端除了支持扫码登录外,同时还支持快捷登录,当网站应用发起微信登录请求时,如果用户此时已经登录了微信 3.9.11 for Windows及以上版本客户端,且处于非锁定状态,会优先提示用户使用当前微信客户端已登录的账号进行快速登录。快速登录无需扫码,可直接在Windows设备上进行确认。
# Disable anonymous link creation DISALLOW_ANONYMOUS_LINKS=false
# The daily limit for each user USER_LIMIT_PER_DAY=50
# Create a cooldown for non-logged in users in minutes # Set 0 to disable NON_USER_COOLDOWN=0
# Max number of visits for each link to have detailed stats DEFAULT_MAX_STATS_PER_LINK=5000
# Use HTTPS for links with custom domain CUSTOM_DOMAIN_USE_HTTPS=false
# A passphrase to encrypt JWT. Use a long and secure key. JWT_SECRET=securekey
# Admin emails so they can access admin actions on settings page # Comma seperated ADMIN_EMAILS=
# Invisible reCaptcha secret key # Create one in https://www.google.com/recaptcha/intro/ RECAPTCHA_SITE_KEY= RECAPTCHA_SECRET_KEY=
# Google Cloud API to prevent from users from submitting malware URLs. # Get it from https://developers.google.com/safe-browsing/v4/get-started GOOGLE_SAFE_BROWSING_KEY=
# Your email host details to use to send verification emails. # More info on http://nodemailer.com/ # Mail from example "Kutt <support@kutt.it>". Leave empty to use MAIL_USER MAIL_HOST= MAIL_PORT= MAIL_SECURE=true MAIL_USER= MAIL_FROM= MAIL_PASSWORD=
# The email address that will receive submitted reports. REPORT_EMAIL=
那PDF能不能在小程序直接预览呢?我尝试用微信小程序的web-view里显示PDF的文件,在开发工具里可以显示,但在真机里无法显示。在微信开放社区看有人用PDF.js在浏览器里打开PDF文件,PDF.js 由 Mozilla 提供支持,目标是创建一个通用的、基于 Web 标准的平台,用于解析和呈现 PDF. 通过web-view方式打开通过PDF.js解析的PDF文件,在微信开发工具里无法正常显示,不过好消息是:在真机里可以显示正常。