Home >Common Problem >The difference and association between uri and url
The difference and association between uri and url
URI is a uniform resource identifier, which is used to uniquely identify a resource.
Every resource available on the Web, such as HTML documents, images, video clips, programs, etc., is located by a URI. The URI generally consists of three parts: ① The naming mechanism for accessing the resource ② The host where the resource is stored Name ③The name of the resource itself, represented by the path, with emphasis on the resource.
URL is a uniform resource locator. It is a specific URI, that is, the URL can be used to identify a resource and also specifies how to locate the resource.
URL is a string used to describe information resources on the Internet. It is mainly used in various WWW client programs and server programs, especially the famous Mosaic. URLs can be used to describe various information resources in a unified format, including files, server addresses and directories, etc. URLs generally consist of three parts: ① protocol (or service method) ② the IP address of the host where the resource is stored (sometimes including the port number) ③ the specific address of the host resource. Such as directory and file names, etc.
URN, uniform resource name, unified resource naming, identifies resources by name, such as mailto:java-net@java.sun.com.
URI is an abstract, high-level concept that defines unified resource identification, while URL and URN are specific ways of identifying resources. Both URL and URN are a type of URI. Loosely speaking, every URL is a URI, but not necessarily every URI is a URL. This is because URIs also include a subclass, the Uniform Resource Name (URN), which names the resource but does not specify how to locate the resource. The mailto, news, and isbn URIs above are all examples of URNs.
In Java's URI, a URI instance can represent absolute or relative, as long as it conforms to the syntax rules of URI. The URL class not only conforms to the semantics, but also contains information to locate the resource, so it cannot be relative. In the Java class library, the URI class does not contain any methods for accessing resources. Its only function is to parse. In contrast, the URL class opens a stream to a resource.
The above is the detailed content of The difference and association between uri and url. For more information, please follow other related articles on the PHP Chinese website!