decodeURIComponent() function is the
rawurldecode() function. However, you could also use the PHP
urldecode() function. The difference between the two is in the way they decode literal plus sign (i.e. "
+") present in the URL query string:
+into a space character;
decodeURIComponent()) will not decode the
+sign into any other character.
decodeURIComponent('+') === '+'; // true
<?php rawurldecode('+') === '+'; // true
<?php urldecode('+') === ' '; // true
Both PHP functions are valid and have their use cases. Therefore, depending on your use case you can choose either one.
Please note that you do not need to explicitly use
$_REQUEST array elements, as they're automatically decoded by PHP.
Hope you found this post useful. It was published . Please show your love and support by sharing this post.