Skip to content

Instantly share code, notes, and snippets.

@missinglink
Created March 20, 2012 00:33
Show Gist options
  • Save missinglink/2129047 to your computer and use it in GitHub Desktop.
Save missinglink/2129047 to your computer and use it in GitHub Desktop.
A complete HACK to emulate most of functionality of http_build_url() from http_pecl
/**
* A complete HACK to emulate most of functionality of http_build_url() from http_pecl
*/
ob_start();
empty( $this->scheme ) || printf( '%s://', $this->scheme );
empty( $this->user ) || printf( '%s%s@', $this->user,
empty( $this->pass ) ?'': sprintf( ':%s', $this->pass ));
empty( $this->host ) || print( $this->host );
empty( $this->port ) || printf( ':%d', $this->port );
empty( $this->path ) ? print( '/' ) : print( $this->path );
empty( $this->query ) || printf( '?%s', $this->query );
empty( $this->fragment ) || printf( '#%s', $this->fragment );
return ob_get_clean();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment