0

When I said simple string It works fine, but when I send my public_key string in the same way, It shows error.

I have tried the urlencode() method.

<iframe src="http://local.abc.com/formulaList?id=<?php echo $public_key; ?>"  >
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119

2 Answers2

2

base64() doesn't work because its output can contain slashes (and anyway, most public key strings are already base64 encoded)

htmlspecialchars() escapes HTML special chars as its name implies which has nothing to do with urls (for example, é will be converted to &eacute;)

urlencode() is the right function to use but keep in mind an URL shouldn't be too long as explained in this SO answer

What problem did you encounter when using urlencode() ?

Mouradif
  • 2,666
  • 1
  • 20
  • 37
-2

I write something this might work.

$url =  htmlspecialchars("wdsd@ccddsd*");
header("Location: https://www.google.com?key={$url}");

this will work for you!

Mr Perfect
  • 116
  • 8