php – 如何将一个漂亮的页面标题转换为有效的URL字符串?

想象一下包含UTF-8中几个单词的任何给定语言(英语,阿拉伯语,日语等)的页面标题字符串.例:
$stringRAW = "Blues & μπλουζ Bliss's ブルース Schön";

现在,这实际上需要转换为该页面的URL的有效部分:

$stringURL = "blues-μπλουζ-bliss-ブルース-schön"

just check out this link
这也适用于我的服务器!

Q1. What characters are allowed as valid URL these days? I remember having seen whol arabic strings sitting on the browser and i tested it on my apache 2 and all worked fine.

我猜它必须成为:$stringURL =“blues-blows-bliss-black”

Q2. What existing PHP functions do you kNow that encode/convert these UTF-8 strings correctly for URL ripping them off of any invalid chars?

我至少猜到了:
1.空格应转换成破折号 –
2.删除无效字符?他们是谁? @和’&’?
3.将所有字母转换为小写(或者是在网址中有效的capitcal字母?)

谢谢:非常感谢您的建议!

我会用:
$stringURL = str_replace(' ','-',$stringURL); // Converts spaces to dashes
$stringURL = urlencode($stringURL);

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...