Category: Php / Pear / Mysql / Node.js

git: 命令行添加项目到 git 仓库, Adding an existing project to GitHub using the command line, 添加项目到 git 空仓库

建立一个新仓库,为了避免错误,直接创建 .gitignore, README.md等文件。 Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. 打开终端。Open Terminal. 转换到想要上传的项目目录。Change the current working directory to your local project. git 初始化。… Read More

PHP: 生成颜色,颜色处理,随机生产颜色,TinyColor,随机色彩,随机色系

项目地址:https://github.com/mistic100/RandomColor.php 下载 JS:randomColor.js 下载 PHP:RandomColor.php   Random Color   Options You can pass an options object to influence the type of color it produces. The options object accepts the following properties: hue – 控制颜色的色调,你可以输入色彩的颜色名称,例如:red, orange, yellow, green, blue, purple, pink 和 mono… Read More

phpMyAdmin报错:Problem with phpMyAdmin and PHP 7.2: “Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”

phpmyadmin报错: Some errors have been detected on the server! Please look at the bottom of this window. [Ignore All] [Ignore] This is the output when [users] table has been clicked: (but it shows the records at the top) this is found at the bottom===> `Notice in ./libraries/dbi/DBIMysqli.class.php#522 Undefined offset: 245 Backtrace ./libraries/Dat… Read More

MySQL: 修改默认编码, MySQL / MariaDB: Set Character Set and Collation to UTF8, Mysql2::Error: Incorrect string value: ‘\xE2\x80\xA8\x09

发现phpmyadmin默认是latin字符编码,导致某些特殊字符,或者乱码字符无法保存,常有的报错类似: Mysql2::Error: Incorrect string value: '\xE2\x80\xA8\x09   1. 那么首先看一下我们的mysql默认字符是什么:   sudo mysql mysql> status -------------- mysql Ver 14.12 Distrib 5.0.45, for Win32 (ia32) Connection id: 25 Current database: spiel0 Current user: root@localhost SSL:

PHP: Gearman实现分布式处理, 分布式任务分发框架Gearman教程

一. 场景分析 业务服务压力比较大,想把一些占用资源的功能异步到远程处理,比如记录业务日志,文件加密,文件分发到其他文件服务器节点上,检查文件服务器是否已同步,对用户上传的图片进行剪裁生成多份缩略图,视频转换,静态内容生成,清除缓存等等,这些请求耗时长,占用系统资源大,影响业务正常访问。这些问题会经常遇到的,如果这些任务都在用户请求过程中完成,服务器撑不撑得住暂不考虑,单凭用户体验角度考虑来说,那是难以忍受的。 二. 解决之道 对于这种需求,我们可以通过分布式计算,对任务进行拆分,转移到多台服务器上进行异步或同步处理。分布式消息队列有多种实现方式如rabbitmq、gearman等。 在这里主要说gear… Read More

PHP使用CURL详解,CURL实例,CURL爬虫,CURL采集,CURL Restful(POST、GET、PUT、DELETE)

PHP使用CURL详解 Curl是一个非常强大的开源库,支持很多协议,包括HTTP、FTP、TELNET等,我们使用它来发送HTTP请求。它给我 们带来的好处是可以通过灵活的选项设置不同的HTTP协议参数,并且支持HTTPS。CURL可以根据URL前缀是“HTTP” 还是“HTTPS”自动选择是否加密发送内容。 使用方法 使用CURL的PHP扩展完成一个PHP的请求,一般分为四个步骤: 初始化Curl连接句柄 设置属性选项 执行获取结果,处理异常 关闭Curl连接句柄 基本结构 (1)初始化 curl_init() (2)设置变量curl_setopt() (3)执行并获取结果curl_exec() (4)释放cURL句… Read More

phpmyadmin导入或导出超大数据库文件的解决方法

一般网站经常用phpmyadmin备份和恢复数据库,但默认总是限制了2M。网站数据太多就不行了。 解决方法有两种,如下: (方法一)修改php.ini适用自己有服务器或VPS的朋友 大多数都修改php.ini中的upload_max_filesize,但修改了这个以后,还是提示这个问题; 那么更改如下几处: 修改 PHP.ini (Ubuntu位置:/etc/php/7.0/apache2/php.ini) file_uploads on  #是否允许通过HTTP上传文件的开关。默认为ON即是开 upload_tmp_dir  #文件上传至服务器上存储临时文件的地方,如果没指定就会用系统默认的临时文件夹 upload… Read More

Ubuntu: 安装/开启Apache PHP curl模块 How to enable curl, installed Ubuntu LAMP stack?

Open SSH First Install CURL by typing sudo apt-get install curl Then Restart Apache by typing sudo service apache2 restart Then Install PHP5 CURL by typing sudo apt-get install php5-curl 如果您使用的是7.0版块,可以尝试 sudo apt-get install php7.0-curl Then Restart Apache by typing sudo service apache2 restart Done! 更多可以参考:https://stackoverflow.com/ques… Read More

WordPress : 设置WP首页自动转向另一个页面How to create a redirect from a home page to any URL using the PHP redirect

In order to add a redirect function to your WordPress template, you should perform the following: Log into your Dashboard and go to Appearance -> Editor, select Home Page Page Template (page-home.php): If you don’t have the Home Page page template in your theme folder, you should copy it there. To do that, you need to copy the file page-home… Read More

PHP: 通过字母大小写分割字符,大写字符分割到数组, php explode at capital letters?

I have strings like, $a = 'helloMister'; $b = 'doggyWaltz'; $c = 'bumWipe'; $d = 'pinkNips'; How can I explode at the capital letters, search on google for some time and came back with nothing! Thanks. 解决: If you want to split helloMister into hello and Mister you can use preg_split to split the string at a point just before the uppercase letter

Mysql: 格式化日期, 时间戳到日期, Convert timestamp to date in MySQL query

定义和用法 DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。 语法 DATE_FORMAT(date,format) date 参数是合法的日期。format 规定日期/时间的输出格式。 实例 下面的脚本使用 DATE_FORMAT() 函数来显示不同的格式。我们使用 NOW() 来获得当前的日期/时间: DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p') DATE_FORMAT(NOW(),'%m-%d-%Y') DATE_FORMAT(NOW(),'%d %b %y') DATE_FORMAT(NOW(),'%d %b %Y %T:%f') 结果类似: Dec 29 2008 11:45 PM 12-29-2… Read More

PHP: 遍历出两个时间之间的日期 Date function to display all dates between two dates

There is the DatePeriod class. EXAMPLE: $begin = new DateTime('2013-02-01'); $end = new DateTime('2013-02-13'); $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end); foreach($daterange as $date){ echo $date->format("Y-m-d") . "<br>"; } (P1D stands for period of one day, see DateInterval for further documentation) $pe… Read More