Home >Backend Development >PHP Tutorial >How to escape special characters in url links
This article introduces the method of escaping special characters in URL links. Learn how to escape characters. Friends in need can refer to it.
Special characters in the URL address have special uses in the URL and cannot be passed directly in the URL. URL encoding is required. The encoding format is: % plus the ASCII code of the character, that is, a percent sign %, followed by the ASCII (hexadecimal) code value of the corresponding character. URL special characters need to be escaped 1. Replace spaces with plus signs (+) 2. Forward slash (/) separates directories and subdirectories 3. Question mark (?) separates url and query 4. The percent sign (%) specifies special characters 5. Bookmark designated by # 6. Ampersand separates parameters URL special symbols and corresponding hexadecimal value encoding: 1. The + sign in + url represents a space %2b 2. Spaces in the URL can be marked with a + sign or encoded with %20 3. / separates directories and subdirectories %2f 4. ? Separate the actual url and parameters %3f 5. % specifies the special character %25 6. # represents bookmark %23 7. & Separator between parameters specified in url %26 8. = The value of the parameter specified in the url %3d Function to handle url escape characters in js escape, encodeuri, encodeuricomponent php filter parameter special characters anti-injection php method to filter illegal and special strings php example: example of special character processing function php code to replace special characters in extra long text |