Laravel是一套簡潔、優雅的PHP Web開發架構(PHP Web Framework)。它可以讓你從麵條一樣雜亂的程式碼中解脫出來;它可以幫你建立一個完美的網路APP,而且每行程式碼都可以簡潔、富於表達力。 在Laravel中已經具有了一套高級的PHP ActiveRecord實作 -- Eloquent ORM。它能方便的將「約束(constraints)」應用到關係的雙方,這樣你就具有了對數據的完全控制,而且享受到ActiveRecord的所有便利。 Eloquent原生支援Fluent中查詢建構器(query-builder)的所有方法。
<?php use \mageekguy\atoum; define('COVERAGE_TITLE', 'MetaYaml'); define('COVERAGE_DIRECTORY', './web/coverage'); define('COVERAGE_WEB_PATH', 'http://localhost/meta-yaml/coverage'); if(false === is_dir(COVERAGE_DIRECTORY)) { mkdir(COVERAGE_DIRECTORY, 0777, true); } $script->addTestAllDirectory(__DIR__ . '/test'); $stdOutWriter = new atoum\writers\std\out(); $coverageField = new atoum\report\fields\runner\coverage\html(COVERAGE_TITLE, COVERAGE_DIRECTORY); $coverageField->setRootUrl(COVERAGE_WEB_PATH); $cliReport = new atoum\reports\realtime\cli(); $cliReport ->addWriter($stdOutWriter) ->addField($coverageField, array(atoum\runner::runStop)) ; $runner->setBootstrapFile('test/bootstrap.php'); $runner->addReport($cliReport);XML就是可擴展標記語言,標準通用標記語言的子集,是一種用於標記電子文件使其具有結構性的標記語言。 在電子計算機中,標記指電腦所能理解的資訊符號,透過此種標記,電腦之間可以處理包含各種的資訊例如文章等。它可以用來標記資料、定義資料類型,是一種允許使用者對自己的標記語言進行定義的來源語言。它非常適合萬維網傳輸,提供統一的方法來描述和交換獨立於應用程式或供應商的結構化資料。是Internet環境中跨平台的、依賴內容的技術,也是現今處理分散式結構資訊的有效工具。早在1998年,W3C就發布了XML1.0規範,使用它來簡化Internet的文件資訊傳輸。
文字處理工具多執行緒操作,測試10萬行文字替換、分割、取出暫無錯誤,分割、取出較慢,替換較快<?php use KzykHys\Text\Text; /** * @author Kazuyuki Hayashi <hayashi@valnur.net> */ class TextTest extends \PHPUnit_Framework_TestCase { public function testInitialize() { $constructed_text = new Text('foo'); $this->assertInstanceOf('KzykHys\Text\Text', $constructed_text); $created_text = Text::create('foo'); $this->assertInstanceOf('KzykHys\Text\Text', $created_text); $this->assertEquals($constructed_text, $created_text); } public function testAppend() { $text = new Text('foo'); $this->assertEquals('foobar', $text->append('bar')); } public function testPrepend() { $text = new Text('foo'); $this->assertEquals('barfoo', $text->prepend('bar')); }#
public function addDeviceParser($parser) { if (is_string($parser) && class_exists('DeviceDetector\Parser\Device\' . $parser)) { $className = 'DeviceDetector\Parser\Device\' . $parser; $parser = new $className(); } if ($parser instanceof DeviceParserAbstract) { $this->deviceParsers[] = $parser; return; } throw new \Exception('device parser not found'); }UUID 是 一般唯一識別碼(Universally Unique Identifier)的縮寫,是一種軟體建構的標準,也是開放軟體基金會組織在分散式運算環境領域的一部分。其目的,是讓分散式系統中的所有元素,都能有唯一的辨識訊息,而不需要透過中央控制端來做辨識資訊的指定。如此一來,每個人都可以創建不與其它人衝突的UUID。在這樣的情況下,就不需要考慮資料庫建立時的名稱重複問題。目前最廣泛應用的UUID,是微軟公司的全域唯一識別碼(GUID),而其他重要的應用,則有Linux ext2/ext3檔案系統、LUKS加密分割區、GNOME、KDE、Mac OS X等等。另外我們也可以在e2fsprogs套件中的UUID庫找到實作。
public function addClientParser($parser) { if (is_string($parser) && class_exists('DeviceDetector\Parser\Client\' . $parser)) { $className = 'DeviceDetector\Parser\Client\' . $parser; $parser = new $className(); } if ($parser instanceof ClientParserAbstract) { $this->clientParsers[] = $parser; self::$clientTypes[] = $parser->getName(); return; } throw new \Exception('client parser not found'); }你想要一個小巧的框架;你需要出色的性能;你需要廣泛兼容標準主機上的各種PHP 版本和配置;你想要一個幾乎零配置的框架;你想要一個不需要使用命令列的框架;你想要一個不想被編碼規則的條條框框限制住的框架;你對PEAR 這種龐然大物不感興趣;你不想被迫學習新的模板語言(當然如果你喜歡,你可以選擇一個模板解析器);你不喜歡複雜,追求簡單;那麼這款輕量級的PHP標記解析庫就是你想要的! <?php /** * @copyright 2006-2014, Miles Johnson - http://milesj.me * @license https://github.com/milesj/decoda/blob/master/license.md * @link http://milesj.me/code/php/decoda */ error_reporting(E_ALL | E_STRICT); // Set constants define('TEST_DIR', __DIR__); define('VENDOR_DIR', dirname(TEST_DIR) . '/vendor'); define('DECODA', str_replace('\', '/', dirname(TEST_DIR) . '/src/Decoda/')); // Ensure that composer has installed all dependencies if (!file_exists(VENDOR_DIR . '/autoload.php')) { exit('Please install Composer in Decoda\'s root folder before running tests!'); } // Include the composer autoloader $loader = require VENDOR_DIR . '/autoload.php'; $loader->add('Decoda', TEST_DIR);#
public function __call($methodName, $arguments) { foreach (DeviceParserAbstract::getAvailableDeviceTypes() as $deviceName => $deviceType) { if (strtolower($methodName) == 'is' . strtolower(str_replace(' ', '', $deviceName))) { return $this->getDevice() == $deviceType; } } foreach (self::$clientTypes as $client) { if (strtolower($methodName) == 'is' . strtolower(str_replace(' ', '', $client))) { return $this->getClient('type') == $client; } } throw new \BadMethodCallException("Method $methodName not found"); }開源,全稱為開放原始碼。開源就是要使用者利用原始碼在其基礎上修改和學習的,但開源系統同樣也有版權,同樣也受到法律保護。 市場上開源軟體層出不窮,很多人可能認為開源軟體最明顯的特點是免費,但實際上並不是這樣的,開源軟體最大的特點應該是開放,也就是任何人都可以得到軟體的原始碼,加以修改學習,甚至重新發放,當然是在版權限制範圍之內。 開源系統其實面向的用戶有兩個群體,一是程式設計師,他們最關心原始碼,能不能進行二次開發利用;二是普通終端用戶,他們只關心軟體功能夠不夠強。開源系統的重點應該是在“開放”,是接納、包容和發展,求同存異,互利共贏,才是開源的本質。
class DeviceDetector { /** * Current version number of DeviceDetector */ const VERSION = '3.9.1'; /** * Holds all registered client types * @var array */ public static $clientTypes = array(); /** * Operating system families that are known as desktop only * * @var array */ protected static $desktopOsArray = array('AmigaOS', 'IBM', 'GNU/Linux', 'Mac', 'Unix', 'Windows', 'BeOS', 'Chrome OS'); /** * Constant used as value for unknown browser / os */ const UNKNOWN = "UNK";User Agent中文名為使用者代理,簡稱UA,它是一個特殊字串頭,使得伺服器能夠識別客戶使用的作業系統及版本、CPU 類型、瀏覽器及版本、瀏覽器渲染引擎、瀏覽器語言、瀏覽器插件等。 有些網站常常透過判斷UA 來傳送不同的作業系統、不同的瀏覽器不同的頁面,因此可能造成某些頁面無法在某個瀏覽器中正常顯示,但透過偽裝UA 可以繞過檢測。 瀏覽器的UA 字符串標準格式為:瀏覽器標識(作業系統標識; 加密等級標識; 瀏覽器語言) 渲染引擎標識版本資訊
<?php /* * This file is part of ansi-to-html. * * (c) 2013 Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SensioLabs\AnsiConverter; use SensioLabs\AnsiConverter\Theme\Theme; /** * Converts an ANSI text to HTML5. */ class AnsiToHtmlConverter { protected $theme; protected $charset; protected $inlineStyles; protected $inlineColors; protected $colorNames; public function __construct(Theme $theme = null, $inlineStyles = true, $charset = 'UTF-8') { $this->theme = null === $theme ? new Theme() : $theme; $this->inlineStyles = $inlineStyles; $this->charset = $charset; $this->inlineColors = $this->theme->asArray(); $this->colorNames = array( 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', '', '', 'brblack', 'brred', 'brgreen', 'bryellow', 'brblue', 'brmagenta', 'brcyan', 'brwhite', );ANSI是一種字元代碼,為使電腦支援更多語言,通常使用 0x00~0x7f 範圍的1 個位元組來表示 1 個英文字元。超出此範圍的使用0x80~0xFFFF來編碼,即擴展的ASCII編碼。 為使電腦支援更多語言,通常使用 0x80~0xFFFF 範圍的 2 個位元組來表示 1 個字元。例如:漢字 '中' 在ANSI編碼ANSI編碼#中文作業系統中,使用 [0xD6,0xD0] 這兩個位元組儲存。 不同的國家和地區制定了不同的標準,由此產生了 GB2312、GBK、GB18030、Big5、Shift_JIS 等各自的編碼標準。這些使用多個位元組來代表一個字元的各種漢字延伸編碼方式,稱為 ANSI 編碼。在簡體中文Windows作業系統中,ANSI 編碼代表 GBK 編碼;在繁體中文Windows作業系統中,ANSI編碼代表Big5;在日文Windows作業系統中,ANSI 編碼代表 Shift_JIS 編碼。 不同 ANSI 編碼之間互不相容,當訊息在國際間交流時,無法將屬於兩種語言的文字,儲存在同一段 ANSI 編碼的文本中。 ANSI編碼表示英文字元時用一個字節,表示中文用兩個或四個位元組。
<?php require_once __DIR__.'/../vendor/autoload.php'; use HeyUpdate\Emoji\UnicodeUtil; $configFile = __DIR__.'/../config/index.json'; $template = <<<'TEMPLATE' <?php TEMPLATE; if (!is_file($configFile)) { throw new InvalidArgumentException(sprintf('The emoji config file "%s" does not exist', $configFile)); } $emojis = json_decode(file_get_contents($configFile), true); if ($emojis === false) { throw new InvalidArgumentException(sprintf('Unable to parse the emoji config file "%s"', $configFile)); }#
<?php if(php_sapi_name() !== "cli") { echo "<p>Run this php script from the command line to see CLI syntax highlighting and formatting. It support Unix pipes or command line argument style.</p>"; echo "<pre><code>php examples/cli.php \"SELECT * FROM MyTable WHERE (id>5 AND \`name\` LIKE \"testing\");\"</code></pre>"; echo "<pre><code>echo \"SELECT * FROM MyTable WHERE (id>5 AND \`name\` LIKE \"testing\");\" | php examples/cli.php</code></pre>"; } if(isset($argv[1])) { $sql = $argv[1]; } else { $sql = stream_get_contents(fopen("php://stdin", "r")); } require_once(__DIR__.'/../lib/SqlFormatter.php'); echo SqlFormatter::format($sql);簡單地說,格式化就是為磁碟做初始化的工作,以便我們能夠按部就班地往磁碟上記錄資料。好比我們有一所大房子要用來存放書籍,我們不會搬來書往屋里地上一扔了事,而是要先在裡面支起書架,標上類別,把書分門別類地放好。 結構化查詢語言(Structured Query Language)簡稱SQL,結構化查詢語言是一種資料庫查詢和程式設計語言,用於存取資料以及查詢、更新和管理關係資料庫系統; sql 語句就是對資料庫進行操作的一種語言。
<?php namespace Stringy; if (!function_exists('Stringy\create')) { /** * Creates a Stringy object and returns it on success. * * @param mixed $str Value to modify, after being cast to string * @param string $encoding The character encoding * @return Stringy A Stringy object * @throws \InvalidArgumentException if an array or object without a * __toString method is passed as the first argument */ function create($str, $encoding = null) { return new Stringy($str, $encoding); } }字串主要用於編程,概念說明、函數解釋、用法詳述見正文,這裡補充一點:字串在儲存上類似字元數組,所以它每一位的單一元素都是可以提取的,如s=“abcdefghij”,則s[1]=“a”,s[10]="j",而字串的零位正是它的長度,如s[0]=10(※上述功能Ansistring沒有。),這可以給我們很多方便,如高精度運算時每一位都可以轉換為數字存入數組。 字串或字串(String)是由數字、字母、底線組成的一串字元。一般記為 s=“a1a2···an”(n>=0)。它是程式語言中表示文字的資料類型。在程式設計中,字串(string)為符號或數值的一個連續序列,如符號串(一串字元)或二進位數字串(一串二進位數字)。 通常以字串的整體作為操作對象,如:在字串中尋找某個子字串、求取一個子字串、在字串的某個位置上插入一個子字串以及刪除一個子字串等。兩個字串相等的充要條件是:長度相等,且各個對應位置上的字元都相等。設p、q是兩串,求q在p中首次出現的位置的運算叫做模式匹配。串的兩種最基本的儲存方式是順序儲存方式和連結儲存方式。
數位訊號處理,英文:Digital Signal Processing,縮寫為DSP,是面向電子資訊學科的專業基礎課,它的基本概念、基本分析方法已經滲透到了資訊與通訊工程,電路與系統,積體電路工程,生物醫學工程,物理電子學,導航、導引與控制,電磁場與微波技術,水聲工程,電機工程,動力工程,航空工程,環境工程等領域。 數位訊號處理問題無所不在,資訊科學已滲透到所有現代自然科學和社會科學領域。我們應該熟練地掌握、基本理論和基本分析方法,並利用這些經典理論分析、解釋和計算訊號、系統及其相互之間約束關係的問題。 <?php require_once(__DIR__ . '/../vendor/autoload.php'); // Let's consider some really basic examples. echo '<pre>'; // Adding up elements in an array. But wait! First we need an array... // Let's get a random sample of 50 values, in the range 0, 100. $random = NumbersPHP\Statistic::randomSample(0, 100, 50); echo 'Random = {' . implode(', ', $random) . "}\n"; // Add them up... $sum = NumbersPHP\Basic::sum($random); echo 'Sum of Random = ' . $sum . "\n"; // We can do some other cool stuff as well. Like find the GCD between // two integers. $gcd = NumbersPHP\Basic::gcd(100, 10); echo 'GCD amongst 100 and 10 = ' . $gcd; echo '</pre>';#