LOADING

分类 PHP 下的文章

内容PHPGolang具体实现PHP具体实现Golang特殊说明
数据类型布尔型,字符串,整型,浮点型,数组,对象,资源,空值 。布尔型,整型,浮点型,复数型,字符型,字符串型,错误类型,指针,数组,切片,字典,通道,结构体,接口。$name = "白色彩虹"Golang数据类型变量声明Golang中声明的变量必须使用,否则编译报错
单元格单元格

流程
准备工作

  1. 注册google账号
  2. 创建结算账号
  3. 创建项目 https://console.cloud.google.com/projectselector2/iam-admin/serviceaccounts?hl=zh_CN
  4. 创建服务账号
  5. 创建服务账号的秘钥,下载到本地
  6. 设置有秘钥的服务账号资源权限
  7. composer require google/cloud-translate

代码

require 'vendor/autoload.php';

use Google\Cloud\Translate\V3\TranslationServiceClient;

$translationClient = new TranslationServiceClient();
$content = ['one', 'two', 'three']; //数组形式可传多个
$targetLanguage = 'es'; 目标语言
$response = $translationClient->translateText(
    $content,
    $targetLanguage,
    TranslationServiceClient::locationName('[PROJECT_ID]', 'global') // project_id是你的项目id,global是你秘钥的本地地址
);

foreach ($response->getTranslations() as $key => $translation) {
    $separator = $key === 2
        ? '!'
        : ', ';
    echo $translation->getTranslatedText() . $separator;
}

 // 传值
        $a = 123;
        $b = $a;
        $a = 456;
        echo $b; // 123
        // 传引用
        $a = 123;
        $b = &$a;
        $a = 456;
        echo $b; // 456
        // 对象例外会默认传引用
        $a = AdminUser::get();
        echo $a->count();// 130
        $b = $a;
        $a = $a->forget(129);
        echo $b->count();// 129 
        // 所以如果要缓存变量需要clone 关键字
        $a = AdminUser::get();
        echo $a->count();// 130
        $b = clone $a;
        $a = $a->forget(129);
        echo $b->count();// 130 

新建github项目 并拉取到本地
本地执行composer init 初始化
打开composer.json编辑配置

{
    "name": "wangsitong/perfect-curl",
    "description": "easy curl for requests", 
    "type": "library", 
    "authors": [
        {
            "name": "wangsitong",
            "email": "512350703@qq.com"
        }
    ],
    "require": {
        "php": "^5.6|^7.0"
    },
    "minimum-stability": "dev",
    "license": "MIT",
    "keywords": [
        "curl",
        "wangsitong",
        "perfect-curl"
    ],
    "autoload": {
        "psr-4": {
            "PerfectCURL\\": "src/"
        }
    }
}

composer install 添加自动加载
WechatIMG1346.png

更新代码至github
使用github账号登录 https://packagist.org
点击submit
将你的项目的 github 地址 填到那个 input 中
点击check, 检测 composer.json 是否有误

异常处理:
Warning from https://mirrors.aliyun.com/composer: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See

或者提示找不到对应版本
composer self-update新包只支持composer2.0

https://github.com/wang-sitong/perfect-curl

https://packagist.org/packages/wangsitong/perfect-curl

composer require wangsitong/perfect-curl

配置 laravels
安装 swoole
安装 inotify
安装 laravels

  1. 安装 swoole
  2. http://pecl.php.net/get/swoole-4.4.19.tgz

tar -zxvf swoole-4.4.19.tgz
cd swoole-4.4.19
phpize
./configure
make && make install
注意 make install 需要 sudo 或使用 root 账号

查看 swoole 版本
php --ri swoole
重启 php
DEV 服务器使用 PHP7.3
/usr/local/php7.3/bin/phpize
./configure --with-php-config=/usr/local/php7.3/bin/php-config
添加扩展
sudo vim /usr/local/php7.3/etc/conf.d/modules.ini
启动 laravels
sudo -u www-data php7.3 artisan laravels restart

  1. 安装 inotify
  2. https://pecl.php.net/get/inotify-2.0.0.tgz

tar -zxvf inotify-2.0.0.tgz
cd inotify-2.0.0/
phpize
./configure
make && make install
注意 make install 需要 sudo 或使用 root 账号

查看 inotify 版本
php --ri inotify

  1. 安装 laravels
    使用 composer 安装

composer require "hhxsv5/laravel-s"
发布 laravels 配置文件

php artisan laravels publish
扩展阅读
swoole 官网
laravels Github

$toTime = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($oneSheet->getCell("A" . $j)->getValue());
$day = date('Y-m-d',$toTime);

结合方向 运算符 附加信息
无 clone new clone和new<
左 [ array()
右 ** 算术运算符
右 ++ -- ~ (int) (float) (string) (array) (object) (bool) @ 类型和递增/递减
无 instanceof 类型
右 ! 逻辑运算符
左 * / % 算术运算符
左 + - . 算术运算符和字符串运算符
左 << >> 位运算符
无 < <= > >= 比较运算符
无 == != === !== <> <=> 比较运算符
左 & 位运算符和引用<
左 ^ 位运算符
左 | 位运算符
左 && 逻辑运算符
左 || 逻辑运算符
左 ?? 比较运算符
左 ? : 三元运算符
右 = += -= = *= /= .= %= &= |= ^= <<= >>= 赋值运算符
左 and 逻辑运算符
左 xor 逻辑运算符
左 or 逻辑运算符

//示例代码
$status = $appAd->status ?? 0 == AppAdvertisement::APP_STATUS_SHOW && strpos($appAd->ad_type ?? '', 'splash') !== false ? 1 : 0;

今天在创建软连接的时候报了个语法错误
php artisan storage:link
完整错误信息如下
PHP Parse error: syntax error, unexpected '=' in /srv/test/server_dev/vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 384
原因是因为这个服务器上有多个php版本,7.0以下的版本会出问题
php7.3 artisan storage:link
解决

X5内核是不支持ios系统的!!!X5内核是不支持ios系统的!!!X5内核是不支持ios系统的!!!

X5内核判断的逻辑非常复杂,如果你的需求是必须是X5内核的话最好还是用以下判断最为准确,TBS是腾讯浏览服务的意思
这么写百分百是只有x5显示,但是实测 只有qq可以展示,微信是没有的
所以最终的逻辑如下, android端 ua中包括 TBS,或包含micromessenger
js

if(ua.match(/TBS/i) == "tbs" && ua.match(/MQQBrowser/i) == "mqqbrowser"){
                show_gdt()
            }

php

trpos($ua, 'TBS') !== false && strpos($ua, 'MQQBrowser') !== false;