<?php error_reporting(E_ALL | E_STRICT); // Ensure that composer has installed all dependencies if (!file_exists(dirname(__DIR__) . DIRECTORY_SEPARATOR . '/vendor/autoload.php')) { die("Dependencies must be installed using composer:\n\nphp composer.phar install --dev\n\n" . "See http://getcomposer.org for help with installing composer\n"); } // Include the Composer autoloader $loader = include realpath(dirname(__FILE__) . '/../vendor/autoload.php');在PHP里提供了大数字的操作类,有的类是用于高精度计算,其中BigInteger类是针对大整数的处理类,而BigDecimal类则是针对大小数的处理类。下边我们介绍BigDecimal类:BigDecimal 的实现利用到了BigInteger,不同的是BigDecimal加入了小数的概念。一般的float型和Double型数据只可以用来做科学计算或者 是工程计算,由于在商业计算中,要求的数字精度比较高,所以要用到java.math.BigDecimal类,它支持任何精度的定点数,可以用它来精确 计算货币值。
<?php require_once '../src/MischiefCollective/ColorJizz/Autoloader.php'; MischiefCollective\ColorJizz\Autoloader::register(); use MischiefCollective\ColorJizz\Formats\Hex; echo Hex::create(0x00096A)->toCIELCh()->toHex()->hue(230);这个类是php转换或者处理颜色的类,可以把任意颜色转换为其反色的方法。分享给大家供大家参考。这段php代码可以把一个颜色变成与之相反的颜色编码,如:白色变成黑色,蓝色变成黄色
<?php /* * Copyright (C) 2016 Nicolas Grekas - p@tchwork.com * * This library is free software; you can redistribute it and/or modify it * under the terms of the (at your option): * Apache License v2.0 (http://apache.org/licenses/LICENSE-2.0.txt), or * GNU General Public License v2.0 (http://gnu.org/licenses/gpl-2.0.txt). */ /** * Normalizer plugs Patchwork\PHP\Shim\Normalizer as a PHP implementation * of intl's Normalizer when the intl extension in not enabled. */ class Normalizer extends Patchwork\PHP\Shim\Normalizer { }UTF-8(8-bit Unicode Transformation Format)是一种针对Unicode的可变长度字符编码,又称万国码。由Ken Thompson于1992年创建。现在已经标准化为RFC 3629。UTF-8用1到6个字节编码Unicode字符。用在网页上可以统一页面显示中文简体繁体及其它语言
测量单位:用于表示与其相比较的同 <?php namespace PhpUnitsOfMeasureTest; use PhpUnitsOfMeasure\UnitOfMeasure; class UnitOfMeasureTest extends \PHPUnit_Framework_TestCase { /** * @covers \PhpUnitsOfMeasure\UnitOfMeasure::__construct * @covers \PhpUnitsOfMeasure\UnitOfMeasure::getName */ public function testGetName() { $uom = new UnitOfMeasure( 'quatloos', function ($valueInNativeUnit) { return $valueInNativeUnit; }, function ($valueInThisUnit) { return $valueInThisUnit; } ); $this->assertEquals('quatloos', $uom->getName()); }种量大小的约定定义和采用的特定量。中文名 测量单位 定 义 约定定义和特定量 单位符号 m 又 名 计量单位定义:用于表示与其相比较的同种量大小的约定定义和采用的特定量。①约定地赋予测量单位以名称和符号。如长度的单位名称为米,单位符号为m。②同量纲的量即使这些量不是同种量,其单位可有相同的名称和符号。如功、热、能量,单位都是焦尔(J)。③测量单位在我国又称计量单位。
<?php namespace OAuth\Common; /** * @author ieter Hordijk <info@pieterhordijk.com> */ class AutoLoader { /** * @var string The namespace prefix for this instance. */ protected $namespace = ''; /** * @var string The filesystem prefix to use for this instance */ protected $path = ''; /** * Build the instance of the autoloader * * @param string $namespace The prefixed namespace this instance will load * @param string $path The filesystem path to the root of the namespace */ public function __construct($namespace, $path) { $this->namespace = ltrim($namespace, '\'); $this->path = rtrim($path, '/\') . DIRECTORY_SEPARATOR; }OAUTH协议为用户资源的授权提供了一个安全的、开放而又简易的标准。同时,任何第三方都可以使用OAUTH认证服务,任何服务提供商都可以实现自身的OAUTH认证服务,因而OAUTH是开放的。业界提供了OAUTH的多种实现如PHP、JavaScript,Java,Ruby等各种语言开发包,大大节约了程序员的时间,因而OAUTH是简易的。互联网很多服务如Open API,很多大公司如Google,Yahoo,Microsoft等都提供了OAUTH认证服务,这些都足以说明OAUTH标准逐渐成为开放资源授权的标准。
OAUTH协议为用户资源的授权提供了一个安全的、开放而又简易的标准。同时,任何第三方都可以使用OAUTH认证服务,任何服务提供商都可以实现自身的OAUTH认证服务,因而OAUTH是开放的。业界提供了OAUTH的多种实现如PHP、JavaScript,Java,Ruby等各种语言开发包,大大节约了程序员的时间,因而OAUTH是简易的。互联网很多服务如Open API,很多大公司如Google,Yahoo,Microsoft等都提供了OAUTH认证服务,这些都足以说明OAUTH标准逐渐成为开放资源授权的标准。
<?php namespace Dflydev\Hawk\Client; use Dflydev\Hawk\Credentials\Credentials; use Dflydev\Hawk\Nonce\NonceProviderInterface; use Dflydev\Hawk\Time\TimeProviderInterface; class ClientTest extends \PHPUnit_Framework_TestCase { /** * @test */ public function shouldCreateBewit() { $client = ClientBuilder::create()->build(); $tentTestVectorsCredentials = new Credentials( 'HX9QcbD-r3ItFEnRcAuOSg', 'sha256', 'exqbZWtykFZIh2D7cXi9dA' ); $this->assertEquals( 'ZXhxYlpXdHlrRlpJaDJEN2NYaTlkQVwxMzY4OTk2ODAwXE8wbWhwcmdvWHFGNDhEbHc1RldBV3ZWUUlwZ0dZc3FzWDc2dHBvNkt5cUk9XA', $client->createBewit( $tentTestVectorsCredentials, 'https://example.com/posts', 0, array( 'timestamp' => 1368996800, ) ) ); } }超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。所有的WWW文件都必须遵守这个标准。设计HTTP最初的目的是为了提供一种发布和接收HTML页面的方法。1960年美国人Ted Nelson构思了一种通过计算机处理文本信息的方法,并称之为超文本(hypertext),这成为了HTTP超文本传输协议标准架构的发展根基。Ted Nelson组织协调万维网协会(World Wide Web Consortium)和互联网工程工作小组(Internet Engineering Task Force )共同合作研究,最终发布了一系列的RFC,其中著名的RFC 2616定义了HTTP 1.1。
<?php include(dirname(__FILE__).'/../lib/emoji.php'); header('Content-type: text/plain; charset=UTF-8'); $GLOBALS['failures'] = 0; $test_unified= "Hello ".utf8_bytes(0x2649); $test_iphone= "Hello ".utf8_bytes(0xE240); $test_docomo= "Hello ".utf8_bytes(0xE647); $test_kddi= "Hello ".utf8_bytes(0xE490); $test_google= "Hello ".utf8_bytes(0xFE02C); $test_html= "Hello ".test_html(2649); is(emoji_docomo_to_unified($test_docomo),$test_unified, "DoCoMo -> Unified"); is(emoji_kddi_to_unified($test_kddi),$test_unified, "KDDI -> Unified"); is(emoji_softbank_to_unified($test_iphone),$test_unified, "Softbank -> Unified"); is(emoji_google_to_unified($test_google),$test_unified, "Google -> Unified"); echo "#------------------\n有时候我们得到表情字符串想让它对应的显示表情,那这样的话该怎么做呢?前段时间就遇到了这方面的需求,在请求数据的时候,后台返回的字符串中包含 :sad: 这类型的表情字符串,如果直接将内容放到Label上显示,那么显示的也是 :sad: 这样的形式找了很多资料,发现都得用图文混排的方式去处理,其中很多的表情字符串是[大哭]这样的形式,然后对于:sad:这样的形式就又有点懵逼了,后来用正则的方式去处理了,发现确实好用,同时也处理了tableviewCell的自适应高度问题。emoji表情转换PHP库就完美的解决了这个问题
今天给大家带来在多台远程机器上并行运行的命令行的PHP库,我们下面来看一段代码。<?php namespace League\Shunt; use League\Shunt\Contracts\SCPInterface; use League\Shunt\Contracts\SessionInterface; use League\Shunt\BaseObject; use Symfony\Component\Console\Output\OutputInterface; use RuntimeException; class SCP extends BaseObject implements SCPInterface { protected $session; public function __construct(SessionInterface $session, OutputInterface $output) { // Set the base object properties parent::__construct($session, $output); if ( ! $session->valid()) throw new RuntimeException('SSH connection failed.'); $this->session = $session; } public function put($localFile = '', $remoteFile = '') { return $this->doRun(__METHOD__, func_get_args(), ssh2_scp_send($this->session->getConnection(), $localFile, $remoteFile)); } public function get($remoteFile = '', $localFile = '') { return $this->doRun(__METHOD__, func_get_args(), ssh2_scp_recv($this->session->getConnection(), $remoteFile, $localFile)); } }
大家都知道,有很多方法可以进行标记解析,今天我们就带来利用轻量级的标记来解析的PHP库,一起来看一下。 <?php namespace Decoda; use Decoda\Decoda; use Decoda\Loader\FileLoader; use Decoda\Test\TestCase; use Decoda\Test\TestComponent; class ComponentTest extends TestCase { protected function setUp() { parent::setUp(); $this->object = new TestComponent(array('key' => 'value')); } public function testAddGetLoaders() { $this->assertEquals(0, count($this->object->getLoaders())); $this->object->addLoader(new FileLoader(TEST_DIR . '/config/test.php')); $this->assertEquals(1, count($this->object->getLoaders())); } public function testGetSetConfig() { $this->assertEquals('value', $this->object->getConfig('key')); $this->assertEquals(null, $this->object->getConfig('foobar')); $this->object->setConfig(array('key' => 'foo')); $this->assertEquals('foo', $this->object->getConfig('key')); } public function testGetSetParser() { $this->assertEquals(null, $this->object->getParser()); $this->object->setParser(new Decoda()); $this->assertInstanceOf('Decoda\Decoda', $this->object->getParser()); } public function testMessage() { $this->object->setParser(new Decoda()); $this->assertEquals('Quote by {author}', $this->object->message('quoteBy')); } }
我们知道。命令是在操作系统中,提示进行命令输入的一种工作提示符。在不同的操作系统环境下,命令提示符各不相同。在windows环境下,命令行程序为cmd.exe,是一个32位的命令行程序,微软Windows系统基于Windows上的命令解释程序,类似于微软的DOS操作系统。输入一些命令,cmd.exe可以执行,比如输入shutdown -s就会在30秒后关机。总之,它非常有用。打开方法:开始-所有程序-附件 或 开始-寻找-输入:cmd/cmd.exe 回车。它也可以执行BAT文件。这次小编给大家总结了一些简单的命令行包装的PHP库,我们一起来看一下。<?php require_once __DIR__ . '/../vendor/autoload.php'; use MrRio\ShellWrap as sh; // List all files in current dir echo sh::ls(); // Touch a file to create it sh::touch('file.html');
cron计划任务,是任务在约定的时间执行已经计划好的工作,这是表面的意思。在Linux中,我们经常用到 cron 服务器来完成这项工作。cron服务器可以根据配置文件约定的时间来执行特定的作务。<?php namespace Cron; abstract class AbstractField implements FieldInterface { protected $fullRange = []; protected $literals = []; protected $rangeStart; protected $rangeEnd; public function __construct() { $this->fullRange = range($this->rangeStart, $this->rangeEnd); } public function isSatisfied($dateValue, $value) { if ($this->isIncrementsOfRanges($value)) { return $this->isInIncrementsOfRanges($dateValue, $value); } elseif ($this->isRange($value)) { return $this->isInRange($dateValue, $value); } return $value == '*' || $dateValue == $value; }