The Book: 50 drops of PHP
This book collects 50 useful, unknown, underrated PHP functions or stuff discovered, used, and learned during PHP's daily use.
Using frameworks daily, sometimes the perception of the power of the language and the basic functionalities provided by the PHP core could be lost. I see that usually, I used to look at the framework documentation or look for a package in Packagist for the system, array, and string functions instead of using some core functionalities provided by the language.
Download the PDF version for FREE
You can download your PDF version here: https://hifolks.gumroad.com/l/50-drops-of-php?price=0
License
"50 drops of PHP" (c) by Roberto Butti
"50 drops of PHP" is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
You should have received a copy of the license along with this work. If not, see http://creativecommons.org/licenses/by-nc-sa/4.0/.
50 drops of PHP
Table of Content
- Welcome to 50 drops of PHP
- The reason why
- Get used PHP version: phpversion()
- Display OS information: php_uname()
- Get memory usage in bytes: memory_get_usage()
- Get environment variable value: getenv()
- How to exit: exit()
- Shutdown function: register_shutdown_function()
- Listening signals: pcntl_signal()
- Loaded PHP modules: get_loaded_extensions()
- Compare versions: version_compare()
- Retrieve the current Process Identifier: getmypid()
- Get resource usage: getrusage()
- Return current UNIX timestamp: microtime()
- Why you need to avoid to use microtime() to measure the time
- Get monotonic time: hrtime()
- Get temporary directory: sys_get_temp_dir()
- Get temp file name: tempnam()
- Array
- Variables, Constants
- Functions
- Strings
- Padding strings: str_pad()
- Converting case of a sentences of strings: mb_convert_case()
- Parse string: sscanf()
- Format a string: sprintf()
- Validating string, alphabetics: ctype_alpha()
- Validating string, digits: ctype_digit()
- Validate strings, lower case letters: ctype_lower()
- Generate unique string: uniqid()
- Store objects or variables: serialize()
- Retrieve saved objects or variables: unserialize()
- Compress content: gzcompress()
- Uncompress content: gzuncompress()
- Delete characters: trim()
- From JSON string to PHP object: json_decode()
- Format a string with an array: vsprintf()
- Files
- Appendix
- Cheat sheet for PHP array functions
- Append arrays
- Joins elements into string
- A section of an array
- Find the first occurrence
- Find the last occurrence
- A function for each element
- All elements match an expression
- At least 1 element matches an expression
- Filter elements
- Apply a function for each element
- Flatten array
- Change some elements
- Apply a function with all elements
- Last element
- Prepends an element
- Add element at the end
- Reverse an array
- Sorting
- Remove/replacing/adding elements
- Stringify and array
- Length
- Is array?
- Cheat sheet for PHP array functions