欢迎来到 艾瑞可erik 的魔法世界 🧙‍♂️

给我一个需求,还你一个项目——别管它是什么。这就是全栈。

📚 291 篇文章 🏷️ 504 个标签 📂 90 个分类

🔥 最新文章

有关composer

composer是php5.3以上 的一个依赖管理工具。简单来说就是你在composer里面可以找到各种优秀的第三方扩展。可以丰富自己的项目节省开发时间。
首先要在你本地win电脑安装composer
安装成功后用命令窗口去安装打开目录执行: echo @php “%~dp0composer.phar” %*>composer.bat
关闭命令窗口重新打开 执行 : composer 结果如图
有关composer

About Composer

Composer is a dependency management tool for PHP 5.3 and above. Simply put, in Composer you can find all kinds of excellent third-party extensions. It can enrich your project and save development time.
First you need to install Composer on your local Windows machine.
Once the installation succeeds, use a command window to install it — open the directory and run: echo @php “%~dp0composer.phar” %*>composer.bat
Close the command window and reopen it, then run: composer. The result is shown in the figure.
About composer

归

夜出鹏城宿羊南, 千里粤豫一日还。 九朝帝王今何在, 洛水小巷今荣繁。 写于2017年春节归途。

Return

By night I leave Pengcheng, to lodge south of Yang; a thousand li from Yue to Yu in a single day. Where now are the emperors of nine dynasties? The lanes by the Luo River thrive today. Written on the road home for the 2017 Spring Festival.

wget抓取网站

最近需要套个模板,当然模板不需去购买。那就抓取一个,百度一下发现wget是个不错的用法。
wget -r -p -np -k https://erik.xyz 就可抓取整个站点模板到本地。

然后打包压缩,拷贝到win电脑就可以修修改改。
顺便查查wget使用方法
-a<日志文件>:在指定的日志文件中记录资料的执行过程;

-A<后缀名>:指定要下载文件的后缀名,多个后缀名之间使用逗号进行分隔;

-b:进行后台的方式运行wget;

Scraping a Website with wget

Recently I needed to adapt a template, and of course I wasn’t going to buy one. So I’d scrape one instead — a quick search turned up wget as a pretty good way to do it.
wget -r -p -np -k https://erik.xyz and you can scrape the whole site’s template to your local machine.

Then package it up, compress it, copy it to a Windows machine and you can tinker with it as you like.
While I was at it I looked up how to use wget
-a: record the execution process in the specified log file;

-A: specify the suffixes of the files to download; separate multiple suffixes with commas;

-b: run wget in the background;

Installing the Sphinx Extension for PHP 7

In the official pecl repository you can only find a Sphinx extension that supports version 5.2. PHP 7 has been out for quite a while, and having no Sphinx isn’t very reasonable. Following a tip from a fellow netizen, on the sphinx page under the pecl repository, click [ Browse Source ] as shown below:

100个常用的 PHP 类库、资源和技巧小结

本文转载自:http://www.scutephp.com/topic-id1325.html 收集整理一些常用的PHP类库, 资源以及技巧. 以便在工作中迅速的查找所需… 100个常用的 PHP 类库、资源和技巧小结

学习资源

php相关的有参考价值的社区,博客,网站,文章,书籍,视频等资源

A Roundup of 100 Commonly Used PHP Libraries, Resources and Tips

This article is reposted from: http://www.scutephp.com/topic-id1325.html A collection of commonly used PHP libraries, resources and tips, so you can quickly find what you need at work… A Roundup of 100 Commonly Used PHP Libraries, Resources and Tips

Learning Resources

Valuable php-related resources for reference: communities, blogs, websites, articles, books, videos and so on

php中xml转换成php数组

1
2
3
4
5
6
7
8
9
10
11
12
public function xmlArray($xml){ 
if(!$xml){
$data="数据异常";
error\_log("数据错误".print\_r($data)."\\r\\n",3,'wx\_error.log');
exit;
}
//将XML转为array
//禁止引用外部xml实体
libxml\_disable\_entity\_loader(true);
$data= json\_decode(json\_encode(simplexml\_load\_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $data;
}

Converting XML to a PHP Array in PHP

1
2
3
4
5
6
7
8
9
10
11
12
public function xmlArray($xml){ 
if(!$xml){
$data="数据异常";
error\_log("数据错误".print\_r($data)."\\r\\n",3,'wx\_error.log');
exit;
}
//Convert XML to an array
//Disable loading of external XML entities
libxml\_disable\_entity\_loader(true);
$data= json\_decode(json\_encode(simplexml\_load\_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $data;
}

php的数据类型

  • 基本类型
    • integer 整型 表示整数
    • float 浮点数 双精度值,表示所有实数
    • string 字符串 表示字符串
    • boolean 布尔值 表示true或false
    • array 数组 保存具有相同类型的多个数据项
    • object 对象 保存类的实例 特殊类型
    • NULL 空 没有被赋值、已经被重置或者被赋值为特殊值NULL的变量就是NULL类型的变量
    • resource 资源 特定内置函数(例如数据库函数)将返回resource类型的变量 必须作为参数传递给其他函数

PHP Data Types

  • Basic types
    • integer — integer type, represents whole numbers
    • float — floating point, double-precision values, represents all real numbers
    • string — string type, represents strings
    • boolean — boolean, represents true or false
    • array — array, holds multiple data items of the same type
    • object — object, holds an instance of a class; a special type
    • NULL — null, a variable that has not been assigned a value, has been reset, or has been assigned the special value NULL is a variable of the NULL type
    • resource — resource, specific built-in functions (for example database functions) return variables of the resource type; they must be passed as arguments to other functions

php操作符

引用操作符 & 引用操作符主要用在关联赋值中,一个变量赋值给另一个变量的时候,先产生原变量的副本,然后再将副本保存在内存中。
例如: $a=1; $b=$a; echo $b; 结果为 1
如果 $a=2; 则 echo $b; 结果还是 1 。
因为$a的赋值副本依然在内存中,赋值依然是第一个值的副本。 这样就用引用操作符 & ,引用操作符会重置原来的指向地址。

PHP Operators

The reference operator & — the reference operator is mainly used in associative assignment. When one variable is assigned to another variable, a copy of the original variable is produced first, and then that copy is saved in memory.
For example: $a=1; $b=$a; echo $b; the result is 1
If $a=2; then echo $b; the result is still 1 .
Because the copy assigned to $a is still in memory, the assignment is still a copy of the first value. So we use the reference operator &, which resets the original address being pointed to.

php超级全局变量

php用了那么久一些基础东西并不是很了解,今天开始就陆陆续续的学习一下。
php中超级全局变量:

  • $GLOBALS 所有全局变量数组
  • $_SERVER 服务器环境变量数组
  • $_GET get传递给脚本的变量数组
  • $_POST post传给脚本的变量数组
  • $_COOKIE cookie变量数组
  • $_FILES 上传文件相关的变量数组
  • $_ENV 环境变量数组
  • $_REQUEST 所有输入用户的变量数组(包括$_GET $_POST $_COOKIE不包括$_FILES) $_SESSION 会话变量数组

PHP Superglobals

I’ve used PHP for so long but don’t really understand some of the basics. Starting today I’ll be studying them one by one.
Superglobals in PHP:

  • $GLOBALS array of all global variables
  • $_SERVER array of server environment variables
  • $_GET array of variables passed to the script via get
  • $_POST array of variables passed to the script via post
  • $_COOKIE array of cookie variables
  • $_FILES array of variables related to file uploads
  • $_ENV array of environment variables
  • $_REQUEST array of all user-input variables (including $_GET $_POST $_COOKIE but not $_FILES) $_SESSION array of session variables

php中if注意事项

最近偶然发现php中if有个自动处理比较的参数

例如

  1. $a=’adasds’; if($a==0){ echo “GGGG”; }else{ echo “KKKK”; } 结果输出 GGGG 这是if判断$a时会检测字符串中最开始有误数字,无数字就返回0 所以返回 GGGG
  2. $a=’55adasds’; if($a==55){ echo “GGGG”; }else{ echo “KKKK”; } 结果 GGGG if判断会检测$a中开头是否有数字,有数字就返回数字,所以结果 GGGG
  3. $a=’ad55asds’;或$a=’adasds55’; if($a==55){ echo “GGGG”; }else{ echo “KKKK”; } 结果 KKKK 说明if判断时检测$a不会检测中间和最后面是否有数字,且结果直接返回0; 综上示例 if判断时如果定义变量是整型就不会出现此问题,如果是字符串就要考虑示例1,2的存在。

Things to Watch Out For with if in PHP

Recently I happened to discover that PHP’s if has an automatically handled parameter for comparisons

For example

  1. $a=’adasds’; if($a==0){ echo “GGGG”; }else{ echo “KKKK”; } The result is GGGG. This is because when if evaluates $a it checks whether there is a number at the very start of the string; if there is no number it returns 0, so the result is GGGG
  2. $a=’55adasds’; if($a==55){ echo “GGGG”; }else{ echo “KKKK”; } The result is GGGG. The if comparison checks whether there is a number at the beginning of $a; if there is a number it returns that number, so the result is GGGG
  3. $a=’ad55asds’; or $a=’adasds55’; if($a==55){ echo “GGGG”; }else{ echo “KKKK”; } The result is KKKK, which shows that when if evaluates $a it does not check whether there is a number in the middle or at the end, and the result simply returns 0; In summary, with if comparisons, if the variable you define is an integer this problem won’t come up, but if it is a string you have to take the situations in examples 1 and 2 into account.