0
我正在使用下面的代碼嘗試轉換爲slug,並且由於某種原因它沒有回顯任何內容。我知道我錯過了一件非常明顯的事情。我是不是在調用這個函數?使用PHP將鏈接轉換爲Slug
<?php
$string = "Can't You Convert This To A Slug?";
function clean($string) {
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
echo $string;
}
?>
什麼是蛞蝓和地方就是你覆蓋成栓的網址是什麼? – Shahar
@Shahar用'WordPress'的說法是'slug'是特定帖子的'URL鍵'。 –
你永遠不會調用該方法...在底部添加'clean($ string);'。 – Shahar