brew set php version code example
Example 1: brew switch php version
brew unlink php@7.4
brew link php@7.3
Example 2: homebrew switch php version
$ brew unlink php@7.4
$ brew link php@8.0 --force --overwrite
brew unlink php@7.4
brew link php@7.3
$ brew unlink php@7.4
$ brew link php@8.0 --force --overwrite