I am not sure exactly what you are asking, but perhaps it is the xsl:attribute command that you are looking for here
<a title="selfPage">
<xsl:attribute name="href">
<xsl:value-of disable-output-escaping="yes" select="$php" />
</xsl:attribute>
<img src="nameOfPic" alt="..." />
</a>
You probably also want to make sure you set the output to "html" too, as what you are possibly trying to output won't be well-formed XML...
<xsl:output method="html" />
EDIT: If you really want to output without escaped value, then I think your only option could be to output as text, and that means writing something like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="yes"/>
<xsl:variable name="php"><![CDATA[<?php echo htmlentities($_SERVER['PHP_SELF']);?>]]></xsl:variable>
<xsl:template match="/">
<a title="selfPage" href="<xsl:value-of select="$php" />" >
<img src="nameOfPic" alt="..." />
</a>
</xsl:template>
</xsl:stylesheet>
EDIT 2 - To avoid escaping all the tag names, another approach is to wrap much of the output in CDATA tags.
Try this XSLT too, which is slightly more readable.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes" />
<xsl:variable name="php"><![CDATA[<?php echo htmlentities($_SERVER['PHP_SELF']);?>]]></xsl:variable>
<xsl:template match="/">
<![CDATA[
<a title="selfPage" href="]]><xsl:value-of disable-output-escaping="yes" select="$php" /><![CDATA[
<img src="nameOfPic" alt="..." />
</a>
]]>
</xsl:template>
</xsl:stylesheet>