PHP is done on the server side.
You coudl use it to relay text form one user to the next but they woudl both have to log into the same session.
A user could log into your site then invite one of their contacts to chat which creates a new chat session. Each time a user submit's their text the server will log that message in a queue until the other user's browser requests it.
On the Web page you'll need something like AJAx to continually querry your PHP pages with the chat session ID to be able to retrieve any new messages that have been queued for sending.
That should work.