整理一个自己用的编码转换方法,不需要知道原字符串的编码,只需要传入字符串,和你想要转换的编码。
/**
* 编码转换
* @param string $char
* @param string $coding
* @return string
*/
public static function convert_char($char, $coding = 'UTF-8')
{
$encode_arr = ['UTF-8', 'ASCII', 'GBK', 'GB2312', 'BIG5', 'JIS', 'eucjp-win', 'sjis-win', 'EUC-JP'];
$encoded = mb_detect_encoding($char, $encode_arr);
if ($encoded)
{
$char = mb_convert_encoding($char, $coding, $encoded);
}
return $char;
} <?php //对比$this和self /* * $this更倾向于对象本身 * */ class Par{ public  ...
(1).创建数据库test ,创建表shop(字段id,total),商品id是1,商品总数10 (2).PHP模拟购买,商品数量大于0才能购买<?php //连接数据库 $con=mysqli_connect("192.168.2.18...
逛公众号文章看到文章"php实现事件监听与触发的方法,你用过吗?",我就好奇了,php又不是asp.net的webform,哪里来的服务端事件监听。于是学习了一波。先看下监听类:class Event { /** &nbs...
(1).config.php 配置文件<?php /** * RabbitMQ_Config */ $config = [ 'host' => ...
<?php $member = new class { public function getInfo() { ...
最近在编写windows php多线程的东西,从官网下载了PHP的线程安全版,尝试开启curl扩展extension=php_curl.dllphp -m 却提示 PHP Startup: Unable to load dynamic library 'C:\php\ext\php_curl...