發表文章

目前顯示的是 4月, 2017的文章

Markdown

[PHP] Variable

變數的轉型 <?php $number = 12345 * 67890 ; echo substr($number, 3 , 1 ); ?> 這段的結果是1 <?php $number = "12345 * 67890" ; echo substr($number, 3 , 1 ); ?> 這段的結果是4,因為把它當成字串來擷取 第四個元素就是4 常數 兩件事: 常數前面不用加$ 只能用define來定義 通常使用大寫來定義 drfine( "ROOT_LOCATION" , "/usr/local/www/" ); $directory = ROOT_LOCATION; 奇奇怪怪的常數: _LINE_ _FILE_ _DIR_ _FUNCTION_ _CLASS_ _METHOD_ _NAMESPACE_ //example: ehco "this is line " . _LINE_ . " of file " . _FILE_; FUNCTION <?php function longdate ($timestamp) { return date( "l F jS Y" , $timestamp); } echo longdate(time()); ?> 變數範圍: 如果只想要變數只在函式內作用的話, 可以使用 $temp 。 區域變數: 來比較一下結果 <?php function longdate ($timestamp) { $temp = date( "l F jS Y" , $timestamp); return "the date is $date" ; } ?> <?php $temp = "the date is ...

[PHP]邏輯運算

邏輯運算 && 高優先 and 低優先 || or ! xor 字串串接 使用句點進行字串串接 $megs = 5; echo “You have”.$megs.“messages”; out put : You have 5 messages 字串類型 $info = ‘this is a $variable’; 使用單引號 那 this is a $variable 整句都是變數 如果使用雙引號 $variavle 會被視為變數 就會傳值進去 若字串中有特殊字元 需用反斜線 \ 處理 而這種方法只適用在雙引號中的字串 echo多行的時候,可用 “” 包起來 或者用 echo<<<_END _END; 值得注意的是結束的標籤定要在新一行的開頭,且後面不得加任何東西,連註解也不行。

[PHP] Coding_Style

coding style http://symfony.com/doc/current/contributing/code/standards.html Coding Standards 3.2 version edit this page When contributing code to Symfony, you must follow its coding standards. To make a long story short, here is the golden rule: Imitate the existing Symfony code. Most open-source Bundles and libraries used by Symfony also follow the same guidelines, and you should too. Remember that the main advantage of standards is that every piece of code looks and feels familiar, it’s not about this or that being more readable. Symfony follows the standards defined in the PSR-0, PSR-1, PSR-2 and PSR-4 documents. 這些規範都是為了統一各個框架各自造輪子的窘境。 Structure Add a single space after each comma delimiter; 每個分號後面都加一個空白 Add a single space around binary operators (==, &&, …), with the exception of the concatenation (.) operator; 邏輯符號後面也要加空白 Place unary operators (!, --, …) adjacent to the affected variable; Always use identical comparison unless you need type juggli...

[PHP] 環境設定

圖片
PHP 參考: 1. http://php.net/manual/en/index.php 2.PHP,MYSQL,JAVASCRIPT 學習手冊 先照著laravel教學安裝環境 https://laravel.com/docs/5.4 install Server Requirements The Laravel framework has a few system requirements. Of course, all of these requirements are satisfied by the Laravel Homestead virtual machine, so it’s highly recommended that you use Homestead as your local Laravel development environment. However, if you are not using Homestead, you will need to make sure your server meets the following requirements: PHP >= 5.6.4 OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenizer PHP Extension XML PHP Extension install vargant 通常要使用laravel需要安裝上面那堆東西,不過通過 homestead 這個設定好的環境,可以免去這些步驟。 不過往下讀,好像發現另一個東西更方便,叫做valet。 https://laravel.com/docs/5.4/valet 我們先安裝php 再安裝 composer 再來安裝 valet brew update 遇到問題 Error: /usr/local is not writable. You should change the ownership and permissions of /usr/local back to your user account: sudo chown -R $(whoami) /usr/local 跟著做 ...