Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send in a get a hexadecimal color?

Tags:

php

For example: index.php?color=#c2c2c2

echo $_GET['color'];

This possibly will not work, so how?

like image 863
Smash Avatar asked Jan 27 '26 13:01

Smash


1 Answers

URL encode what you send in. #, when url encoded, is %23.

On the receiving side, you just need to do:

$color = urldecode($_GET['color']);

To URL encode in javascript:

var color = encodeURIComponent("#c2c2c2");
like image 57
xbonez Avatar answered Jan 29 '26 02:01

xbonez