(PECL gupnp >= 0.1.0)
gupnp_context_get_port — Get the port
$context
   )Get the port that the SOAP server is running on.
   Returns the port number for the current context and FALSE on error.
  
Example #1 Create new UPnP context and get port number
<?php
/* Create the UPnP context */
$context = gupnp_context_new();
if (!$context) {
 die("Error creating the GUPnP context\n");
}
/* Get the port number for the UPnP context */
$port = gupnp_context_get_port($context);
echo $port;
?>