你好,是我琉憶。前端
一個文藝的PHP開發工程師。程序員
很榮幸可以在這裏帶來個人第一本新書——《PHP程序員面試筆試寶典》。web
1、創做過程面試
《PHP程序員面試筆試寶典》是個人第一本書,從寫做到出來總共經歷了一全年的時間。它就像個人孩子同樣,十分的努力去創做,也十分的愛惜,創做實際用了3個月的時間,可是在長達審稿修改的時間卻也用了3個月,剩餘的3個月時間是出版社幾個編輯在幫我審稿修改,對裏面的字句進行斟酌跟我討論修改。在此對他們的付出抱以誠摯真誠的感謝,謝謝大家的付出。正則表達式
這本書是本身第一本出版的書,因此本身格外的愛惜它,也很怕這本書的內容不能知足大衆,生怕被PHPer所嫌棄。在創做這本書的過程當中,時常從讀者的角度去審查它,它是否可以切實的在解答每道面試題上提供幫助,所涉及的知識點是否切實際的回答完善而且正確。而且我也知道本身的能力會有所欠缺,可能作得不夠盡善盡美,但我也已經在此貢獻了本身所可以達到最極致的能力去作好他。若是本書有所欠缺在此但願讀者可以諒解,並能夠對書中有所遺漏或不足之處給我寫郵件進行指點,我將不斷地對《PHP程序員面試筆試寶典》不斷迭代完善,不斷追求極致,幫助更多的PHPer面試成功。個人郵箱:330168885@qq.com(個人QQ:330168885),若是有什麼事情也能夠給我聯繫,我都願意解答而且交流。感謝你,dear 讀者。算法
2、個人書籍簡介數據庫
本書主要針對 PHP 常考的知識點進行了梳理和整理,經過這些知識點,以點爲面、全面系統地幫助讀者發現本身的知識盲點,從而查漏補缺,幫助他們快速構建屬於本身的 PHP 知識架構。因爲這些知識點都是在筆試或面試的過程當中常常遇到的,所以爲了讓讀者可以更深刻地理解這些相關的知識點,本書還在知識點的後面配上了相關的真題與解析,經過真題與解析加深讀者的理解。編程
編者花費了幾個月的時間,對 PHP 的知識點和各大互聯網公司應用的技術和麪試的問題後端
進行了深刻了解。針對面試 PHP 崗位的常考考點,整理出這本《PHP 程序員面試筆試寶典》。設計模式
3、章節介紹
上篇:面試筆試經驗技巧篇
想找到一份程序員的工做,一點技術都沒有顯然是不行的,可是,只有技術也是不夠的。面試筆試經驗技巧篇主要提供PHP程序員面試筆試經驗、面試筆試問題方法討論等。經過本篇的學習,求職者必將獲取到豐富的應試技巧與方法。
下篇:面試筆試技術攻克篇
面試筆試技術攻克篇主要針對近3年以來近百家頂級IT企業的面試筆試真題而設計,這些企業涉及面很是普遍,面試筆試真題難易適中,很是具備表明性與參考性。本篇對這些真題以及其背後的知識點進行了深度剖析,而且對部分真題進行了庖丁解牛式的分析與講解,針對真題中涉及的部分重難點問題,本篇都進行了適當的擴展與延伸,力求對知識點的講解清晰而不紊亂,全面而不囉嗦,使得讀者可以經過本書不只獲取到求職的知識,同時更有針對性地進行求職準備,最終可以收穫一份滿意的工做。
第1章 PHP基礎知識
PHP也稱爲超文本預處理器,是一種開源的服務端腳本語言。目前,在全球擁有的100萬站點中,有70%左右的站點是使用PHP開發的,PHP被普遍地應用於各類服務端前端及應用的開發。在面試筆試中PHP基礎知識常常被考到,經過基礎知識能夠了解一個PHP程序員的功底如何。若是連PHP基礎都沒能掌握的人,那麼很難在筆試中勝出。因此熟練地掌握PHP基礎知識顯得很是重要。這一章節將詳細地介紹全部可能考到的PHP基礎知識。
第2章PHP Web與框架
由於PHP是內嵌在Web的腳本語言,因此PHP和Web是分不開的。而爲了不由於PHP與Web代碼的高度混雜在一塊兒致使閱讀性和維護性問題而產生了框架,合理地分開了先後端開發人員的工做。因爲web和框架都是PHP開發中必不可少的東西,因此在面試中也是重要考點,做爲開發者是必須熟練掌握各類主流的MVC框架的,由於在實際開發中常常用到。
第3章PHP進階知識
本章主要針對PHP的時間和日期管理、緩存、文件、驗證碼等部分進行講解。在一個項目的實際開發中,都須要涉及這些知識,它會穿插在整個項目中。在面試中問得比較多的是時間和緩存相關的問題,只要是涉及數據的存儲都須要和時間打交道,而緩存是爲了提升網站的打開速度而必定要使用的技術。
第4章 設計模式
不管是PHP仍是Java,都時常會考到設計模式,瞭解透設計模式的人能夠很快知道在什麼場景下采用哪一種代碼的設計是合理的、穩定的、可擴展的,這樣能夠幫助團隊在設計的前期減小問題的產生。而熟練掌握面向對象開發的人不必定懂得設計模式,但懂得設計模式的人能夠熟練懂得面向對象,因此經過設計模式能夠看出一我的對面向對象的掌握熟練程度,而且懂得設計模式的人還能夠開發出一套模板或框架。對PHP程序員來講,由於設計模式是很是重要的,因此在面試中常常考到。
第5章 數據庫
數據庫是按照數據結構來組織、存儲和管理數據的倉庫。從最簡單的存儲各類數據的表格數據到現在進行海量數據存儲都要用到數據庫。PHP主要負責客戶端和數據庫的交互,隨着用戶訪問一個網站的量的增長,PHP每次請求一次數據庫都須要耗費內存和訪問時間,從而加大服務器的壓力和下降網頁的訪問速度。因此現在的公司都要求每一個PHP開發人員須要懂得數據庫的合理設計、優化。高併發訪問的網站對數據庫的設計維護要求更高,須要引入Memcache或Redis緩存來減小對數據庫的請求,從而提升用戶的訪問速度。本章詳細介紹MySQL的知識、優化和常考題目。
第6章 操 做 系 統
對於計算機系統而言,操做系統充當着基石的做用,它是鏈接計算機底層硬件與上層應用軟件的橋樑,控制其餘程序的運行,而且管理系統相關資源,同時提供配套的系統軟件支持。對於專業的程序員而言,掌握必定的操做系統知識必不可少,由於無論面對的是底層嵌入式開發,仍是上層的雲計算開發,都須要使用到必定的操做系統相關知識。因此,對操做系統相關知識的考查是程序員面試筆試必考項之一。
第7章 網 絡
在20世紀80年代,計算機網絡誕生,它可以將一臺臺獨立的計算機互相鏈接,使得位於不一樣地理位置的計算機之間能夠進行通訊,實現信息傳遞和資源共享,造成一組規模大、功能強的計算機系統。不過,計算機要想在網絡中正常通訊,必須遵照相關網絡協議的規則,經常使用的網絡協議有TCP、UDP、IP和HTTP等。
第8章 大數據
計算機硬件的擴容確實能夠極大地提升程序的處理速度,但考慮到其技術、成本等方面的因素,它並不是一條放之四海而皆準的途徑。而隨着互聯網技術的發展,雲計算、物聯網、移動通訊技術的興起,每時每刻,數以億計的用戶產生着數量巨大的信息,海量數據時代已經來臨。因爲經過對海量數據的挖掘能有效地揭示用戶的行爲模式,加深對用戶需求的理解,提取用戶的集體智慧,從而爲研發人員決策提供依據,提高產品用戶體驗,進而佔領市場,因此當前各大互聯網公司都將研究重點放在了海量數據分析上,可是,只寄但願於硬件擴容是很難知足海量數據分析須要的,如何利用現有條件進行海量信息處理已經成爲各大互聯網公司亟待解決的問題。因此,海量信息處理正日益成爲當前程序員筆試面試中一個新的亮點。
4、寶典的目錄
《PHP 程序員面試筆試寶典》整本書涵蓋的知識目錄包括:面試經驗技巧、PHP常考基礎知識、PHP面向對象和設計模式的知識點、PHP進階知識、數據庫常考的MySQL的知識點、計算機網絡相關的知識點,除此以外還額外增長了操做系統的常考知識,和常考的大數據知識點等。幫助每一個PHP程序員面試更順利。
整本書的目錄:
上篇:面試筆試經驗技巧篇
經驗技巧1 如何巧妙地回答面試官的問題······································································· 2
經驗技巧2 如何回答技術性的問題················································································· 3
經驗技巧3 如何回答非技術性問題················································································· 4
經驗技巧4 如何回答快速估算類問題·············································································· 5
經驗技巧5 如何回答算法設計問題················································································· 6
經驗技巧6 如何回答系統設計題···················································································· 8
經驗技巧7 如何解決求職中的時間衝突問題·································································· 11
經驗技巧8 若是面試問題曾經碰見過,是否要告知面試官·············································· 12
經驗技巧9 在被企業拒絕後是否能夠再申請·································································· 12
經驗技巧10 如何應對本身不會回答的問題··································································· 13
經驗技巧11 如何應對面試官的「激將法」語言····························································· 13
經驗技巧12 如何處理與面試官持不一樣觀點這個問題······················································ 14
經驗技巧13 什麼是職場暗語······················································································· 14
經驗技巧14 如何進行自我介紹?················································································· 18
經驗技巧15 如何克服面試中緊張的情緒?··································································· 19
經驗技巧16 如何準備集體面試?················································································· 21
經驗技巧17 如何準備電話面試?················································································· 23
經驗技巧18 簽約和違約須要注意哪些事情?································································ 24
下篇:面試筆試技術攻克篇
第1章 PHP基礎知識································································································· 29
1.1 PHP語言········································································································· 29
1.1.1 PHP與ASP、JSP有什麼區別?···································································· 29
1.1.2 PHP與HTML有什麼區別?········································································· 31
1.1.3 PHP的優勢是什麼?··················································································· 32
1.1.4 PHP的輸出語句有哪些?············································································· 33
1.1.5 如何區分單引號與雙引號?·········································································· 35
1.1.6 什麼是XML?··························································································· 37
1.2 面向對象技術··································································································· 40
1.2.1 面向對象與面向過程有什麼區別?································································· 40
1.2.2 面向對象的特徵是什麼?············································································· 41
1.2.3 面向對象的開發方式有什麼優勢?································································· 41
1.2.4 類與對象的區別是什麼?············································································· 41
1.2.5 PHP5 中魔術方法有哪些?··········································································· 43
1.2.6 值傳遞與引用傳遞有什麼區別?···································································· 51
1.2.7 什麼是對象克隆?······················································································ 52
1.2.8 什麼是延遲靜態綁定?················································································ 56
1.2.9 做用域範圍有哪幾種?················································································ 57
1.2.10 什麼是構造函數?什麼是析構函數?···························································· 58
1.2.11 什麼是繼承?·························································································· 60
1.2.12 抽象類與接口有什麼區別與聯繫?································································ 63
1.2.13 什麼是多態?·························································································· 65
1.3 關鍵字············································································································· 67
1.3.1 final有什麼做用?······················································································ 67
1.3.2 finally有什麼做用?··················································································· 68
1.3.3 assert有什麼做用?···················································································· 69
1.3.4 static有什麼做用?····················································································· 70
1.3.5 global有什麼做用?···················································································· 72
1.3.6 this、self和parent的區別是什麼?································································· 73
1.3.7 include與require有什麼區別?······································································ 75
1.3.8 break、continue與return有什麼區別與聯繫?··················································· 77
1.3.9 switch有什麼做用?··················································································· 79
1.4 常量與變量······································································································ 81
1.4.1 什麼是常量?···························································································· 81
1.4.2 什麼是變量?···························································································· 84
1.4.3 如何判斷變量是否存在、是否爲非空字符或非零?············································ 87
1.4.4 變量的做用域範圍有哪幾種?······································································· 87
1.4.5 如何對變量進行引用?················································································ 89
1.5 數據類型········································································································· 90
1.5.1 基本數據類型有哪些?················································································ 90
1.5.2 如何進行類型轉換?··················································································· 92
1.6 運算符············································································································· 93
1.6.1 運算符的種類有哪些?················································································ 93
1.6.2 ++與—的含義是什麼?·············································································· 100
1.7 字符串··········································································································· 101
1.7.1 字符串處理函數有哪些?··········································································· 101
1.7.2 ==與===有什麼區別?··············································································· 106
1.8 正則表達式···································································································· 106
1.9 函數·············································································································· 111
1.9.1 傳值和引用的區別是什麼?········································································ 111
1.9.2 什麼是默認參數?···················································································· 114
1.9.3 什麼是函數返回值?················································································· 114
1.9.4 如何進行函數調用?················································································· 115
1.10 數組············································································································ 117
1.10.1 如何進行數組的定義與聲明?···································································· 117
1.10.2 什麼是多維數組?··················································································· 121
1.10.3 數組函數有哪些?··················································································· 124
1.11 文件管理······································································································ 130
1.11.1 有哪些文件操做?···················································································· 130
1.11.2 涉及文件操做的函數有哪些?···································································· 134
1.12 異常處理與錯誤處理····················································································· 137
1.12.1 什麼是異常處理與錯誤處理?···································································· 137
1.12.2 error_reporting()的做用是什麼?································································· 138
1.12.3 如何進行異常捕捉與處理?······································································· 139
1.12.4 如何實現自定義的異常類?······································································· 141
1.13 內存管理······································································································ 141
1.13.1 什麼是內存管理?··················································································· 141
1.13.2 什麼是垃圾回收?··················································································· 142
1.14 Redis············································································································ 143
1.14.1 什麼是Redis?······················································································· 143
1.14.2 Redis的常見問題有哪些?········································································ 145
1.15 Memcache····································································································· 147
第2章 PHP Web與框架··························································································· 153
2.1 PHP Web········································································································ 153
2.1.1 Session與Cookie的區別是什麼?································································ 153
2.1.2 GET和POST有什麼區別?········································································ 158
2.1.3 如何預防各種安全性問題?········································································ 160
2.1.4 HTTP狀態碼的含義是什麼?······································································ 161
2.1.5 utf-8編碼須要注意哪些問題?····································································· 164
2.1.6 如何進行網站的優化?·············································································· 165
2.2 模板·············································································································· 166
2.3 框架·············································································································· 167
2.3.1 什麼是MVC?························································································· 167
2.3.2 PHP的開發框架有哪些?··········································································· 168
2.3.3 什麼是CI框架?······················································································ 168
2.4 JavaScript、HTML、CSS等············································································· 171
第3章 PHP進階知識······························································································· 173
3.1 時間和日期管理······························································································ 173
3.1.1 如何輸出年-月-日?················································································· 173
3.1.2 如何輸出時-分-秒?················································································· 174
3.1.3 如何輸出閏年-星期-天?··········································································· 175
3.1.4 PHP相關的日期函數有哪些?····································································· 176
3.2 緩存·············································································································· 179
3.3 文件管理········································································································ 180
3.3.1 PHP中文件操做函數有哪些?····································································· 180
3.3.2 如何進行文件上傳?················································································· 183
3.3.3 如何進行文件下載?················································································· 185
3.3.4 如何進行版本管理?················································································· 186
3.4 驗證碼··········································································································· 187
第4章 設計模式········································································································· 188
4.1 常見的設計模式有哪些?················································································ 188
4.2 什麼是單例模式?·························································································· 190
4.3 什麼是工廠模式?·························································································· 191
4.4 什麼是觀察者模式?······················································································· 192
第5章 數據庫············································································································ 196
5.1 數據庫基礎知識······························································································ 196
5.1.1 SQL語言的功能有哪些?··········································································· 197
5.1.2 內鏈接與外鏈接有什麼區別?····································································· 199
5.1.3 什麼是事務?·························································································· 200
5.1.4 什麼是存儲過程?它與函數有什麼區別與聯繫?·············································· 202
5.1.5 一二三四範式有何區別?··········································································· 202
5.1.6 什麼是觸發器?······················································································· 204
5.1.7 什麼是遊標?·························································································· 205
5.1.8 若是數據庫日誌滿了,那麼會出現什麼狀況?················································· 206
5.1.9 UNION和UNION ALL有什麼區別?··························································· 206
5.1.10 什麼是視圖?························································································· 207
5.1.11 什麼是數據庫三級封鎖協議?···································································· 207
5.1.12 索引的優缺點························································································· 208
5.2 MySQL基礎知識···························································································· 209
5.2.1 PHP操做MySQL的函數有哪些?································································ 210
5.2.2 PHP鏈接MySQL的方法是什麼?································································ 211
5.2.3 MySQLi訪問數據庫的方法········································································· 214
5.2.4 如何進行MySQL操做?············································································ 218
5.2.5 MySQL支持哪些字段類型?······································································· 227
5.2.6 什麼是索引?·························································································· 230
5.2.7 什麼是數據庫引擎?················································································· 232
5.2.8 如何進行數據庫分頁?·············································································· 233
5.2.9 什麼是數據庫權限?················································································· 237
5.2.10 PHP Web訪問MySQL方法是什麼?··························································· 238
5.2.11 如何高效操做MySQL?··········································································· 240
5.3 MySQL高級管理···························································································· 240
5.3.1 如何對MySQL進行優化?········································································· 240
5.3.2 如何進行數據庫優化?·············································································· 244
5.3.3 如何進行數據庫操做優化?········································································ 247
5.3.4 如何進行數據庫表優化?··········································································· 249
第6章 操做系統······································································································· 255
6.1 進程管理········································································································ 255
6.1.1 進程與線程有什麼區別?··········································································· 255
6.1.2 線程同步有哪些機制?·············································································· 256
6.1.3 內核線程和用戶線程的區別········································································ 256
6.2 內存管理········································································································ 257
6.2.1 內存管理有哪幾種方式?··········································································· 257
6.2.2 什麼是虛擬內存?···················································································· 258
6.2.3 什麼是內存碎片?什麼是內碎片?什麼是外碎片?··········································· 258
6.2.4 虛擬地址、邏輯地址、線性地址、物理地址有什麼區別?·································· 259
6.2.5 Cache替換算法有哪些?············································································ 259
6.3 用戶編程接口································································································· 261
6.3.1 庫函數調用與系統調用有什麼不一樣?····························································· 261
6.3.2 靜態連接與動態連接有什麼區別?······························································· 261
6.3.3 靜態連接庫與動態連接庫有什麼區別?·························································· 262
6.3.4 用戶態和核心態有什麼區別?····································································· 262
6.3.5 用戶棧與內核棧有什麼區別?····································································· 263
第7章 網絡·············································································································· 264
7.1 TCP/IP··········································································································· 264
7.1.1 協議······································································································ 264
7.1.2 TCP/IP··································································································· 265
7.1.3 常見筆試題····························································································· 265
7.2 RESTful架構風格··························································································· 266
7.2.1 REST····································································································· 266
7.2.2 約束條件································································································ 267
7.2.3 常見筆試題····························································································· 267
7.3 HTTP············································································································ 268
7.3.1 URI和URL···························································································· 268
7.3.2 HTTP協議······························································································ 269
7.3.3 HTTP報文······························································································ 271
7.3.4 HTTP首部······························································································ 272
7.3.5 緩存······································································································ 273
7.3.6 常見筆試題····························································································· 275
7.4 TCP··············································································································· 276
7.4.1 鏈接管理································································································ 276
7.4.2 確認應答································································································ 278
7.4.3 窗口控制································································································ 280
7.4.4 重傳控制································································································ 281
7.4.5 常見筆試題····························································································· 281
7.5 HTTPS··········································································································· 282
7.5.1 加密······································································································ 283
7.5.2 數字簽名································································································ 283
7.5.3 數字證書································································································ 284
7.5.4 安全通訊機制·························································································· 284
7.5.5 常見筆試題····························································································· 286
7.6 HTTP/2.0······································································································· 286
7.6.1 二進制分幀層·························································································· 287
7.6.2 多路通訊································································································ 288
7.6.3 請求優先級····························································································· 288
7.6.4 服務器推送····························································································· 289
7.6.5 首部壓縮································································································ 289
7.6.6 常見筆試題····························································································· 289
第8章 大數據·········································································································· 290
8.1 從大量的URL中找出相同的URL···································································· 290
8.2 求高頻詞········································································································ 290
8.3 找出訪問百度最多的IP··················································································· 291
8.4 在大量的數據中找出不重複的整數··································································· 292
8.5 在大量的數據中判斷一個數是否存在································································ 292
8.6 如何查詢最熱門的查詢串················································································ 293
8.7 統計不一樣電話號碼的個數················································································ 294
8.8 從5億個數中找出中位數················································································ 295
8.9 按照query的頻度排序···················································································· 296
8.10 找出排名前500的數····················································································· 297
附錄 真題及答案······································································································· 298
真題1··················································································································· 298
真題2··················································································································· 300
真題3··················································································································· 303
真題1答案············································································································ 305
真題2答案············································································································ 306
真題3答案············································································································ 308
5、由衷的感謝
做者本名劉恆春,筆名琉憶,在這裏最早感謝的是大神何昊和薛鵬給予的這個機會,讓我有機會參與PHP相關的面試書籍的創做,其次感謝機械工業出版社給予的出版機會。最後由衷的感謝支持個人父母、哥哥姐姐,還有個人朋友,是大家的支持才讓我最終得以完成這本書。還有爲了這本寶典默默付出審稿的幕後工做者們,很是感謝大家,大家辛苦了。
在此對以上幫助過我得以出版PHP面試寶典的人說聲謝謝,很是感謝。
最後由衷的感謝每一位讀者,謝謝大家對本書的支持。