A very simplified version would be something as follows:
2 lines in config.php:
cat config.php
$variable1 = 'foo with bar';
$variable1 = 'foo2 with bar2';
Set Bash $variable1 to last matching instance of $variable1 in config.php, just in case it has been reset. If you want to change it to the first match, simply change tail -1 to head -1 in the following code:
variable1="$(grep -oE '\$variable1 = .*;' config.php | tail -1 | sed 's/$variable1 = //g;s/;//g')"
Confirm Bash variable via echo:
echo "$variable1"
'foo2 with bar2'
Note that this will mostly work for strings. There are many types of PHP variables that cannot be directly converted to Bash variables. The code above will grab the last $variable1 referenced in config.php. Like I said, if that variable has been set multiple times, you can set to the first value or last value by toggling head or tail in the Bash command that sets the variable.