PHP trim() 问题 - 从字符串中删除 "https://",一个奇怪的问题
Issue with PHP trim() - removing "https://" from the string, a strange issue
我正在使用 PHP trim() 从 sting 中删除 https://。
trim('https://www.hakanerenler.net', 'https://')
如果我将 .com 写入该域,它可以正常工作。但如果它是 .net 域,则最后一个 T 会消失。
如果 trim 是 .net
的最后一个 "T",为什么还要考虑
echo trim('https://www.hakanerenler.com', 'https://');
returns "www.hakanerenler.com"
echo trim('https://www.hakanerenler.net', 'https://');
returns "www.hakanerenler.ne"
谢谢
trim
function 删除任何提供的字符,而不是文字匹配。由于 .net
包含一个 t
正在删除它。
你应该使用str_replace()
instead. For more advanced manipulations you could consider parse_url()
我正在使用 PHP trim() 从 sting 中删除 https://。
trim('https://www.hakanerenler.net', 'https://')
如果我将 .com 写入该域,它可以正常工作。但如果它是 .net 域,则最后一个 T 会消失。 如果 trim 是 .net
的最后一个 "T",为什么还要考虑echo trim('https://www.hakanerenler.com', 'https://');
returns "www.hakanerenler.com"
echo trim('https://www.hakanerenler.net', 'https://');
returns "www.hakanerenler.ne"
谢谢
trim
function 删除任何提供的字符,而不是文字匹配。由于 .net
包含一个 t
正在删除它。
你应该使用str_replace()
instead. For more advanced manipulations you could consider parse_url()