You just need to have the proper connection to the database. IE SQL Sever / Postgres. If the data is already in ArcSDE it is probably easier to create a service and publish it. However, since you mentioned reusing code you just need to call the php file in your page. Look at http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_esri_request.html or http://dojotoolkit.org/reference-guide/1.7/dojo/xhrGet.html#dojo-xhrget
The php code needs to return JSON(P)/xml. This is assuming it is available as a web service. David Walsh has a great sample on this method.
http://davidwalsh.name/web-service-php-mysql-xml-json
The other way is working within a php page and doing it all with php,html. For this you will find an incredible amount of info on the web most using mysql (Just google for the db you want). Here is a very bare bones mysql example.
http://devzone.zend.com/12/php-101-part-8-databases-and-other-animals_part-1/
I like that example because the idea is very simple.
Connect, Select, Create, execute, do something with the result.
You can mix and match all of these in your page for example you can build your PHP query dynamically based on the result of an ArcGIS server webservice query. -> Click on parcel and return the parcel ID. Store parcel ID in a variable. Pass Variable into PHP Query. Search records database using that parcel ID number.
Is it possible to have the PHP interact with ArcSDE and/or PostgreSQL databases through the JavaScript API? Yes, If your PHP is set up as a service. (esri.request) If not, use PHP for server side processing.
From your comment -
I think my confusion might spring from where exactly the PHP section fits into the overall system architecture. Basically, I've learned that PostgreSQL tables are referenced within ArcSDE which is then used to create a MXD thus allowing the uploading of data to ArcServer. Where does the PHP component fit in exactly? Does it replace ArcSDE or go on before ArcSDE?
ArcGIS server creates a webservice based on your data. This is what gives you the REST/SOAP endpoint. http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/
Esri does the hardwork and gives you a nice Restful endpoint. All you do is click through a menu. PHP fits in if you need to either connect to another database or simple want to connect to the same database to query and process data. It does not replace ArcSDE in any way. PHP is just a language that you can use. You could also use C#, Java, Ruby, etc.