Homebrew installation of PHP 8.0 fails

I’m having trouble installing php via Homebrew.

I tried following the guide on https://www.geeksforgeeks.org/how-to-install-php-on-macos/.

It worked the first time, then i uninstalled it and tried reinstalling it again and now I get an dyld[41846]: Library not loaded: error (see picture).enter image description here

Does anyone know how to solve it?

To uninstall php i used the command brew uninstall [email protected].

Then i got the message:

The following may be [email protected] configuration files and have not been removed!
If desired, remove them manually with rm -rf:
/usr/local/etc/php

So i removed them with the command:

rm -rf /usr/local/etc/php

NOTE: the guide also says:

**For compilers to find php8.0 you may need to set:

export LDFLAGS=”-L/opt/homebrew/opt/[email protected]/lib”
export CPPFLAGS=”-I/opt/homebrew/opt/[email protected]/include”**

Which I did. I don’t know if these commands affect the reinstallation somehow.