Today I Learned - Rocky Kev

Tagged “php”

  1. TIL how NGINX knows to look for index.html vs index.php

    What happens when visitor hits /foo/bar URL?

  2. TIL php-fpm

    PHP runs as a separated service when using PHP-FPM. By using this PHP version as language interpreter, requests are processed through a TCP/IP socket; so that the Nginx web server only handles the HTTP requests and PHP-FPM interprets the PHP code. The fact of having two separate services is key for increasing efficiency.

  3. TIL the difference between single-threaded & multi-threaded architecture

    For web dev, we don't need it. We're not bottle-necked by the processing power. We're instead bottlenecked by the ability to read files/databases. We can simulate multi-threading (and improve our app's performance) using async/await.

  4. TIL HTTP "No-cache" headers

    Using PHP and apache .htaccess file to force reload

  5. TIL Never deserializing untrusted data

    This happened the most in PHP, because for some reason, PHP developers love to serialize/deserialize objects instead of using JSON, but I’d say almost every case we saw where a server was deserializing a client object and parsing it led to a horrible exploit.

  6. TIL match expression (like switch)

    Use the match($var) method to filter the results to exactly what you want.

  7. TIL Optional Chaining in PHP8

    Optional Chaining in PHP looks very similar to optional chaining in JS

  8. TIL the difference of Closures in Javascript vs PHP

    I never knew PHP and Javascript closures were different.

  9. TIL combining PHP arrays

    array_merge, array_replace, and the (+) union operator

  10. TIL an easy way to populate an data array

    Bonus - I just had to do this in PHP as well, so you get TWO languages for the price of one TIL!

  11. TIL that PHP has an abandoned Gender Library

    This extension, in short, tries to guess the gender of first names.

  12. TIL output buffering in PHP

    If you are outputting a lot of content in php, use ob_start()

  13. TIL How to Summon WordPress in random PHP files

    How to use WordPress Helper functions outside of WordPress

  14. TIL about how to quickly add a WP Theme customizer Option

    You can do a lot of theme customization that auto-loads the page with every setting change. It's a really nice feature.

  15. TIL VScode bracket formatting for PHP

    Intelephense -> Format: Braces: k&r

  16. TIL how to get WordPress functions working in VSCode

    Right out of the box, PHP Intelephense Extension for VSCode will give errors for WordPress code. How to fix.

  17. TIL Default Params in PHP

    Default Params

  18. TIL About various ways to declare WP Options/Settings Page

    After a lot of research, I found two approaches for writing WP option pages with code.

See all tags.