chivincent
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ###### tags: `Modern PHP Primer` # 前言 ## 如何閱讀本書 ### 入門:完全不會程式語言,想接觸 PHP 的讀者 - [附錄A:建立 PHP 執行環境](/v6B3N374Q9iZkBoA6bMIGA) - 依照章節順序,依次閱讀 - 對於 _延伸閱讀_ 的提示,第一次可先跳過不看 - 部份章節開頭會有 _前置知識_,建議先點選連結瞭解前置知識後再閱讀該章節 - 如果對於計算機系統或 C 語言理解不深者,建議跳過 _第四部份:核心剖析_ ### 熟悉:熟悉其它程式語言,或有使用過 PHP7 以前版本的讀者 - 從 [目錄](/OQ1rlq26R2GwoD_ESo3MxQ) 粗略瀏覽一次 _第一部份:語言特性與語法精要_ - 依照章節順序,從 _第二部份:現代 PHP 革命_ 開始閱讀 - 遇到 _延伸閱讀_ 的提示可以直接點擊其中連結 - 部份章節開頭會有 _前置知識_,如果尚不熟悉可以先點選瞭解前置知識後再閱讀該章節 - 如果對於計算機系統或 C 語言理解不深者,建議跳過 _第四部份:核心剖析_ ### 精通:熟稔 PHP7 或以上版本的讀者 - 從 [目錄](/OQ1rlq26R2GwoD_ESo3MxQ) 中的 _第二部份:現代 PHP 革命_ 中挑選有興趣的關鍵字深入探索 - _第三部份:功能概覽_ 挑選有興趣的關鍵字深入瞭解 - 搭配 [PHP RFC](https://wiki.php.net/rfc) 瞭解 PHP 發展的趨勢 - 搭配足夠成熟的 PHP 框架(如 [Laravel](https://laravel.com), [Symfony](https://symfony.com/))瞭解 PHP 的當前生態 - _第四部份:核心剖析_ 挑選有興趣的關鍵字深入瞭解 - 搭配 [PHP Source Code](https://github.com/php/php-src) 與 [PHP Internal Book](https://www.phpinternalsbook.com/) 瞭解底層程式實作與 Zend API 的應用 ## 本書的系統環境與 Coding Style 本書預設使用 PHP 最新版本(PHP 8.1)的語法,並且會隨官方版本更新而同步更新內容。 本書在條件允許的前提下,會盡可能遵守 [PSR-12](https://www.php-fig.org/psr/psr-12/) 的 Coding Style 標準撰寫。 ### 為什麼要用最新版的 PHP? PHP 是個歷史悠久的語言,過時的版本往往伴隨著糟糕的效能與安全性問題。 一般來說,PHP 開發者應該嚴格遵守官方發佈的 [Supported Versions](https://www.php.net/supported-versions.php) 作為版本的最低限度要求,但往往受限於系統環境、框架版本或擴充套件的支援而難以達成。 至少在本書中,無論是新手或專家,都應該能夠享受真正由 Modern PHP 所帶來的語法改進與效能優勢。 ## 本書編輯慣例 ### 字型與字體 **粗體** 表示需要特別注意的內容 _斜體_ 表示專有名詞,其後方會加入其原文名稱 `等寬字` 表示變數或函式的名稱、資料類型、環境變數、單行程式內容及語法關鍵字。 > 引用 表示這段文字引用自其它來源,並於最後標示並連結其來源 ### 提示區塊 :::info 資訊:補充資料,會以藍底的資訊區塊提示 ::: :::warning 警告:需要特別注意的事項,會以黃底的警告區塊提示 ::: :::danger 陷阱:危險的操作,無論如何都應該避免的事項,會以紅底的陷阱區塊提示 ::: ### 範例程式區塊 #### 程式碼 對於大部份的程式碼,存在以下表現方式: ```php= // greeting.php echo 'Hello World'; // Hello World // [more] ``` - 行 1:若以 `//` 開頭,表示檔案名稱 - 為了減少篇幅,一個程式區塊中可能存在多個不同的檔案,都會以 `// {檔案名稱}` 作為提示 - 行 3:敘述後若存在 `//` 表示該程式的輸出值,或變數的值 - 行 5:可能於任何位置存在 `// [more]` 區塊,表示省略不重要的部份 #### Shell :::info Shell 是指在 _[命令列介面(CLI)](https://zh.wikipedia.org/wiki/%E5%91%BD%E4%BB%A4%E8%A1%8C%E7%95%8C%E9%9D%A2)_ 下的執行環境: - Windows 用戶:「命令提示字元」或「Powershell」 - macOS 用戶:「Terminal.app」 本書中所提到的 Shell 是指符合 [POSIX 標準](https://zh.wikipedia.org/wiki/%E5%8F%AF%E7%A7%BB%E6%A4%8D%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E6%8E%A5%E5%8F%A3)的 Shell,例如 [sh](https://zh.wikipedia.org/wiki/Bourne_shell)、[bash](https://zh.wikipedia.org/wiki/Bash) 或 [zsh](https://zh.wikipedia.org/wiki/Z_shell) ::: 對於 Shell 介面,存在以下表現方式: ```shell $ echo "Hello World" Hello World ``` - 對於使用者自行輸入的內容,會以 `$` 開頭 - 對於輸出則直接顯示(不重要的部份會直接省略) ```shell (powershell) > echo "Hello World"; Hello World ``` - 對於非 POSIX 標準的 Shell(例如 powershell),會以 `>` 開頭,並在前方 `()` 顯示其名稱 ## 授權 - 文本內容採用 [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh_TW) 授權 - 程式碼內容採用 [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html) 授權

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully