how to use bitcoind jsonrpc for regtest or testnet server in php? i used bitcoind with jsonrpc service. 

but i added regtest=1 in bitcoin.conf at .bitcoin folder.

used:


  bitcoin-cli -regtest generate 101
  
  bitcoin-cli -regtest getbalance
  
  50.00000000


but I can't see the balance in php.


  $bitcoin->getbalance()


it doesn't show me the balance. it returns nothing.

if I remove regtest=1 from bitcoin.conf and start bitcoind -daemon.


  $bitcoin->getbalance()
  it gives me the the real server balance.


what is solution for this problem???
Very likely you need to tell your PHP JSON RPC client to connect to the right port.

If you start bitcoind without -regtest (= main net), it opens up the RPC server on port 8332.
If you use -regtest, the port will be 18332.

I can't see what kind of PHP JSON RPC client you are using, but there must be a way to tell it should use port 18332.