Often used functions - heikijapan/php-book2 GitHub Wiki
URL related
rawurlencode();
-
Use it when manually building URL using $variables. It encodes special characters like spaces etc into safe url
/profile/Heiki%20%26%20Jane. -
Do not use it to encode the full url like this
http://localhost:3000/heiki/because it will also encode '//' etc and then url may stop functioning! It is meant to be use just for $variable part of URL and NOT FOR SECURITY. It just replaces spaces and some other characters with%etc to avoid broken url's.
http_build_query();
- It builds part of URL after
?from an array
http_build_query(['page' => 10]);
# This function uses an array to build correct url parameters
-
min(1,10)compare 1 and 10, then use smaller number which is 1 in this case. -
max(1,10)compare 1 & 10, and take bigger, 10 in this case.