Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

php - Escape colon in url string

I have a string:

$fonts = "Arial:400";

When I use that in a URL, the colon prints as %3A. How can I escape the colon so that it prints as :? I have tried preg_replace and urlencode with no luck. I'm sure its simple but I have searched.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should be using urlencode and substitute the %3a with :

$url = urlencode($url);
$url = str_replace("%3A",":",$url);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...