Although PHP released its latest version i.e. v 8 , You might be working on a project that is using the old version of PHP i.e either version 7.0 or version 7.1 which is not supported by HomeBrew by default.
On my M1 Mac which comes with OSX Big Sur. I installed the default PHP version 7.3 using HomeBrew but for one of the project which is using Laravel v 5.4 I had to install PHP 7.0 on my Mac.
Here is how I installed it
brew tap exolnet/homebrew-deprecated brew install email@example.com
Now in order switch it to version 7.0 from 7.3 here is what you can do
brew unlink firstname.lastname@example.org brew link email@example.com