These are list of following of reserved characters for links:
! # $ % & ( ) * + , / : ; = ? @ [ ]
These characters need to be encoded so it doesn’t interfere with the function of the URL.
These characters will turn into %21 hexadecimal characters.
A fix for this is
<?php urlencode($string); ?>
URLencode
- Letters, numbers, underscores, and dash are unchanged
- Reserved characters become % + 2 digit hexadecimal
- Spaces become “+”
- Use this for query string after that ?
rawurlencode
- rawurlencode should only be used for file path
- path is the part before “?”
- spaces must be %20
- it’s newer