If you’re using Chrome and Spotify on macOS and the Play/Pause buttons on your keyboard are not working when using Spotify, there’s a simple fix for this.
Continue readingCategory: Notes (Page 2 of 47)
Notes on programming-related problems that I’ve encountered while working on various projects.
At some point, I lost the motivation to write about anything that would include too much code because of the amount of time it would take to:
- put a functioning solution together,
- architect it in such a way that’d fit with best practices (at least for OOP),
- explain the various features about OOP that the reader may not know,
- then explain the problem.
This is too complex.
I’m not saying that articles shouldn’t be written that explain the concepts of object-oriented programming or shouldn’t talk about certain rationale for why something was done.
Continue readingTL;DR: $argv
is an array of arguments passed to the script with the first index being the name of the script itself. And $argc
is the number of arguments passed to the the script (which will always at least be 1
).
Arguably, pun intended, one of the key pieces of command-line application is making sure that they are interactive through command-line arguments. In PHP, there are two variables to understand:
$argc
is the number of arguments passed to script. Note the script’s filename is always passed as an argument to the script, therefore the minimum value of$argc
is1
.$argv
is an array of arguments passed to script. Note the first argument$argv[0]
is always the name that was used to run the script.
TL;DR: I’ve been writing PHP command-line scripts to help automate mundane tasks. As these tasks are growing in complexity or turning more into applications that interface with third-party APIs, I’m documenting the things I find important that others may also find helpful.
There are three things necessary to get a basic script up and running on your local machine (assuming you already have PHP installed):
- Know the path to the PHP binary,
- Make sure your script references said binary,
- And make the script executable.
I never know how many people are reading articles like this the day they are published, but I’ve always been a fan of sharing a note of Thanksgiving Day (at least that’s what it is here in the USA).
