50 drops of PHP

“50 drops of PHP” is an open-source e-book, that you can download it for free here: https://hifolks.gumroad.com/l/50-drops-of-php?price=0 .

This book collects 50 useful, unknown, underrated PHP functions or stuff discovered, used, learned during the P…


This content originally appeared on DEV Community and was authored by Roberto B.

"50 drops of PHP" is an open-source e-book, that you can download it for free here: https://hifolks.gumroad.com/l/50-drops-of-php?price=0 .

This book collects 50 useful, unknown, underrated PHP functions or stuff discovered, used, learned during the PHP daily use.

Using frameworks daily, sometimes the perception of the power of the language and of the basic functionalities provided by the PHP core could be lost. I see that usually I used to look the framework documentation or looking for a package in Packagist for system, array, string functions instead using some core functionalities provided by the language.

Open-source

It is open-source, so you can find Markdown source files and above all, a lot of examples and snippets in this repository:
https://github.com/roberto-butti/50-drops-of-php (feel free to "star" the project on GitHub)

Table of Content

  • Welcome to 50 drops of PHP
    • The reason why
      • Continuous release
      • Where to find this book
      • Thanks to...
  • System
    • Get used PHP version: phpversion()
    • Display OS information: php_uname()
    • Get memory usage in bytes: memory_get_usage()
    • Get environment variable value: getenv()
      • All environment variables
    • How to exit: exit()
      • Exit parameter
    • Shutdown function: register_shutdown_function()
    • Listening signals: pcntl_signal()
    • Loaded PHP modules: get_loaded_extensions()
    • Compare versions: version_compare()
      • Comparing without operator
      • Comparing with operator
    • Retrieve the current Process Identifier: getmypid()
    • Get resources usage: getrusage()
      • The input parameter $mode
    • 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
    • Apply function to each array elements: array_map()
    • A string from an array: join()
    • Check if a key exists in the array: key_exists()
    • Check if an element is included in the array: in_array()
      • Strict comparison
      • Case Sensitive
    • Merge two arrays: array_merge()
      • Key collision: array merge of arrays with numeric keys
      • Key collision: array merge of arrays with strings keys
    • Generate and fill a new array: range()
      • Step
    • Creating array from variables: compact()
  • Variables, Constants
    • Get variable type: gettype()
    • Portable directory separator: DIRECTORY_SEPARATOR
    • Portable end of line: PHP_EOL()
    • Export object properties as array: get_object_vars()
  • Functions
    • Anonymous functions
      • An example with a PHP core function
    • Arrow Functions with PHP
  • Strings
    • Padding strings: str_pad()
    • Converting case of a sentences of strings: mb_convert_case()
    • Parse string: sscanf()
    • Format a string: sprintf()
      • Padding
      • Numbers (integers)
      • Numbers (floats)
      • Formatting cheat sheet
    • 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()
      • Flags
      • Catching errors in parsing
      • Big integers
      • More than one flag
    • Format a string with an array: vsprintf()
  • Files
    • File information: stat()
      • Symbolic link information
    • Parsing directory: scandir()
    • Split filename infos: pathinfo()
    • Create a directory: mkdir()
      • Permissions
      • Nested directories
    • The fingerprint of a file: md5_file()
    • Find files that match a pattern: glob()
    • Read dir: readdir()


This content originally appeared on DEV Community and was authored by Roberto B.


Print Share Comment Cite Upload Translate Updates
APA

Roberto B. | Sciencx (2021-11-12T20:15:21+00:00) 50 drops of PHP. Retrieved from https://www.scien.cx/2021/11/12/50-drops-of-php/

MLA
" » 50 drops of PHP." Roberto B. | Sciencx - Friday November 12, 2021, https://www.scien.cx/2021/11/12/50-drops-of-php/
HARVARD
Roberto B. | Sciencx Friday November 12, 2021 » 50 drops of PHP., viewed ,<https://www.scien.cx/2021/11/12/50-drops-of-php/>
VANCOUVER
Roberto B. | Sciencx - » 50 drops of PHP. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/12/50-drops-of-php/
CHICAGO
" » 50 drops of PHP." Roberto B. | Sciencx - Accessed . https://www.scien.cx/2021/11/12/50-drops-of-php/
IEEE
" » 50 drops of PHP." Roberto B. | Sciencx [Online]. Available: https://www.scien.cx/2021/11/12/50-drops-of-php/. [Accessed: ]
rf:citation
» 50 drops of PHP | Roberto B. | Sciencx | https://www.scien.cx/2021/11/12/50-drops-of-php/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.