我正在尝试使用 urlencode 来转换字符串: <a href="<?php print 'search.php?query='.quote_replace(addmarks($search_results['did_you_mean'])).'&search=1'?>">
实际上,我想实现一个搜索引擎。
|-www
|- index.php
|- search directory
|- search.php
|- header.html
|- search_form.html
|- search_result.html
|- footer.html
search.php includes header.html,search_form.html,search_result.html etc.
我使用以下命令访问 search.php:localhost/index.php/?page=search
search_form.html 包含用于搜索的按钮。它调用 search.php 使用:<form action="index.php/?page=search" method="get">
。我不确定它是否正确。
提交搜索请求后,search.php 调用 search_result.html 显示结果。search_result.html 中的代码:
<a href="<?php print 'search.php?query='.quote_replace(addmarks($search_results['did_you_mean'])).'&search=1'?>"><?php print $search_results['did_you_mean_b']; ?>
它似乎应该可以工作,但是在我单击搜索按钮后,结果 url 是index.php/?query=&search=1
. 我认为它应该是index.php/?page=search/?query=&search=1
。
所以,我尝试使用 urlencode 来解决它。而且我不知道这个想法是否正确。