BIP44 derivation path has five levels:
m / purpose' / coin_type' / account' / change / address_indexIn your case the derivation path is the following:
m / 44' / 0' / 0' / $client_id.' / 0But it should be this:
m / 44' / 0' / $client_id.' / 0' / 0 for receive addresses
m / 44' / 0' / $client_id.' / 1' / 0 for change addresses
The code you have presented in the OP is not suitable for changing an "account" part of the BIP44 derivation path, it only generates receive and change addresses (albeit with non-standard derivation paths) for one account.
Try changing it to something like this, but I am not sure it will work out:
require_once('./HD.php');
$xpub = 'xpub......';
$path = $client_id.'/0'/0';
$hd = new HD();
$hd->set_xpub($xpub);
$address = $hd->address_from_master_pub($path);