我在 youtube 上关注了这个 phpacademy 教程,但无法通过 echo 打印关键字。相反,我得到:
`keywords` LIKE '%keyword%'
什么?代码已逐字复制。可能是平台问题?
这个语句 ->$where .= "
关键字有问题LIKE '%keyword%'";
吗?
<?php
include 'db.inc.php';
function search_results($keywords) {
$returned_results=array();
$where="";
$keywords=preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
foreach($keywords as $key=>$keyword){
$where .= "`keywords` LIKE '%keyword%'"; // Where's the issue?
if($key != ($total_keywords-1)){
$where .= " AND ";
}
}
echo $where;
}
?>