Is it possible to use Bash variable in PHP or get the bash home directory?

According this solution: Temporary change the datadirectory for a OCC
Using OCC works in most situation flawless.

Because I try to experiment a bit with Nextcloud, I need to have an IF command which check either a specific variable or the location of the Home directory.
If it is not possible to use bash variable in PHP I need to check the Existence of a specific directory.

Could someone tell me how I have to change if (\OC::$CLI) { that way?

Do not understand your problem. But pehaps:
(test files and directorys)