Basic page routing in PHP

Last week we talked about setting up a local development server with PHP’s built-in web server and I mentioned that we’d delve into page routing. Routing refers to taking the URI that a person was requested, let’s say /about and routing that to the appropriate code. Sure, you could just have a script named about.php and just make the .php part of the URI....

Read Full Article →

Using PHP’s built-in web server

I recently updated [HolidayAPI][holidayapi] to no longer use my PHP framework because I wanted the system to be easier for new developers to get up and running. Instead of including configuration files for Apache or nginx, I decided that I should just use the web server that’s baked right into PHP! To start up PHP’s built-in web server, from the root of your project...

Read Full Article →

Wonder what’s next?

I have been running this blog since 2013 as a way to improve my PHP as well as my writing. It has been a labor of love and I made it my goal to post at least once a week. At the start of 2015 I decided that I would binge out and write a ton of posts so I would have a backlog...

Read Full Article →

Dynamic variable names a/k/a Variable variables

Variable variables are one of my favorite things about PHP. PHP allows you to use a variable to reference another variable. This comes in exceptionally handy when you need to create variable names dynamically: $variable = 'This is my variable'; $var = 'variable'; echo $$var; Let’s say you have you have a variable that uses another variable as part of the name: $array =...

Read Full Article →

Get all defined variables

I’ve never actually used this function, but could definitely see using it to help profile a system and/or to help identify defined but unused variables. To obtain an array of all of the defined variables you would: $defined = get_defined_vars(); The function returns a multi-dimensional array of all of the defined variables. This is not limited to used-defined variables, so you will end up...

Read Full Article →