Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Created May 19, 2017 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LinzardMac/31ed99f8faa34ffad6e666f213e99870 to your computer and use it in GitHub Desktop.
Save LinzardMac/31ed99f8faa34ffad6e666f213e99870 to your computer and use it in GitHub Desktop.
Pros/Cons of absint()

absint() - WordPress attempt at standardization?

absint() is a WordPress function that passes a string through abs() to turn any negative number into a positive and then intval() which will typecast it as an integer with the above listed “cons” for (int)/inval().

Cons:

  1. Currently there is no way to filter the results before passing the value to the function that queries the database
  2. Does not check for or return a falsey response in case of a malformed ID being passed.
  3. See list for (int)/intval()*

Pros:

  1. Can be passed as a parameter to functions that can accept functions as a parameter such as array_map()
  2. Can be altered as a part of core and not a language defined function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment