- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 315字
- 2021-07-03 00:02:22
PHP7, To Code It Better
PHP7 came with many new features and changes. However, none of them were specifically for REST or web services. In fact, REST does not have any direct relation with language constructs. This is because REST is an architecture, while a language is there to provide constructs for implementation. So, does that mean PHP7 has some construct or feature which can make this implementation better? Yes and no. It depends on what we mean by implementation.
If we mean just getting a request and returning a response then No, there is no such specific feature. But, any RESTful Web Service is related to an entity, and an entity can have its own logic. So to provide RESTful Web Service for that entity, we need to write that logic as well. For this purpose, we will need to write more PHP code than just getting a request and returning a response. So to keep the code simple and clean, yes, PHP7 offers us many things.
I assume that you have the basic knowledge of PHP, as knowing PHP basics is a prerequisite of this book. So, we will not be looking at PHP5. In this chapter, we will be looking at many of the PHP7 features and changes, are either very important to know or we will be using in our code. We are directly going into these features. We are not going in to the details of installing or upgrading to PHP7 because there are dozens of tutorials available for that on the internet. Here is a list of features and changes we are going to discuss:
- Scalar type declaration
- Return type declaration
- Null coalescing operator
- Spaceship operator
- Group use statement
- Generator-related new features
- Generator return expression
- Generator delegation
- Anonymous classes
- Closure::call() function
- Errors and exceptions
- PHP7.1 features
- Nullable types
- Symmetric array destructuring
- Support for keys in list()
- Multi-catch exception handling
- Vue.js 3.x快速入門
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- Fundamentals of Linux
- Vue.js快跑:構建觸手可及的高性能Web應用
- MATLAB應用與實驗教程
- Java Web基礎與實例教程
- Linux環(huán)境編程:從應用到內核
- 從Excel到Python:用Python輕松處理Excel數(shù)據(jù)(第2版)
- 愛上micro:bit
- Python圖形化編程(微課版)
- Python+Tableau數(shù)據(jù)可視化之美
- 編程改變生活:用Python提升你的能力(進階篇·微課視頻版)
- IDA Pro權威指南(第2版)
- TypeScript 2.x By Example
- Delphi開發(fā)典型模塊大全(修訂版)