Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不带数据库的php全文搜索_Php_Full Text Search_Search Engine - Fatal编程技术网

不带数据库的php全文搜索

不带数据库的php全文搜索,php,full-text-search,search-engine,Php,Full Text Search,Search Engine,我有一个用php编写的非常小的网页(大约5页+博客条目)。所有页面都位于服务器端的php文件中(不使用数据库)。到目前为止,我设法在我的“博客条目”中进行搜索,因为它们只是带有HTML标记的纯文本文件(我去掉标记并执行搜索操作): /include/category_1.php <?php ob_start(); require_once("./include/common.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1

我有一个用php编写的非常小的网页(大约5页+博客条目)。所有页面都位于服务器端的php文件中(不使用数据库)。到目前为止,我设法在我的“博客条目”中进行搜索,因为它们只是带有HTML标记的纯文本文件(我去掉标记并执行搜索操作):

/include/category_1.php

<?php ob_start(); require_once("./include/common.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $lang['WEBSITE_TITLE']; ?></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="keyword, keyword, keyword" />
<link href="css/main.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="page">
<!-- Header Area -->
<?php include("./include/header.php"); ?>
<?php include("./include/banner.php"); ?>
<div id="content">

<?php

    $page = '';
    if(isSet($_GET["page"])){
        $page=$_GET["page"];
    }
    switch($page){
        case 'category_1':
            include("./include/category_1.php");
            break;
        case 'about':
            include("./include/category_2.php");
            break;
        case 'contact':
            include("./include/contact.php");
            break;
        default:
            include("./include/home.php");  
    }
?>
<!-- /content --></div> 

<!-- /page --></div>
<br />
<br /><br /><br />

<!-- Footer Area -->
<?php include("./include/footer.php"); ob_end_flush(); ?>

</body>
</html> 
<?php echo '<h2>'.$lang['NAVI_CAT_1'].'</h2>'; ?>

<div id="entry">
<br/>
<?php echo $lang['CAT_1_TEXT']; ?>
</div>


语言文件

<?php
$lang = array();
$lang['NAVI_CAT_1'] = 'Category 1';
$lang['CAT_1_TEXT'] = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.';

?>

为什么不包括在缓冲区中,然后搜索缓冲区的内容

ob_start();
include ('index.php');
$contents = ob_get_clean();
//the $contents now includes whatever the php file outputs

事实上,我在各种产品代码中都使用了这种方法,但主要是在用户发送之前预览网站生成的电子邮件。很好的一点是,您可以在所有文件上使用它,而不仅仅是php文件。

为什么不包括在缓冲区中,然后搜索缓冲区的内容

ob_start();
include ('index.php');
$contents = ob_get_clean();
//the $contents now includes whatever the php file outputs
事实上,我在各种产品代码中都使用了这种方法,但主要是在用户发送之前预览网站生成的电子邮件。好的是,您可以在所有文件上使用它,而不仅仅是php文件。

这是设计失败的。 考虑不要使用简单的混合HTML边。尝试使用xml文件或wathever

另一种选择是爬到自己的一边。看看

这是设计失败的。 考虑不要使用简单的混合HTML边。尝试使用xml文件或wathever



另一种选择是爬到自己的一边。看看

你为什么不干脆忽略这两个页面之间的所有内容呢?如果我们说的是5个页面,那么只需在浏览器中打开它们,将源代码复制到txt文件,并上传到服务器,然后在搜索中使用这些文件。@user574632你刚刚根据http请求发明了file\u get\u contents()。。。用手!;)@Jivan因为那就是我的全部档案了。为了i18n的缘故,我使用了一个语言数组,在相应的页面上显示文本to
echo
。此外,在一个页面中,所涉及的文件不止一个php文件(包括html和css文件、语言文本等)。为了更接近用户574632的方向,您可以设置一条电话线,当用户想要查找表达式时,用户可以通过该电话线给您打电话,因为您对文本了如指掌,您可以告诉他们表达式在页面中的位置。为什么不忽略页面之间的所有内容呢?如果我们谈论的是5个页面,那么只需在浏览器中打开它们,将源代码复制到txt文件,并将其上载到服务器,然后在搜索中使用它们。@user574632您刚刚根据http请求发明了file_get_contents()。。。用手!;)@Jivan因为那就是我的全部档案了。为了i18n的缘故,我使用了一个语言数组,在相应的页面上显示文本to
echo
。此外,在一个页面中,所涉及的文件不止一个php文件(包括html和css文件、语言文本等)。为了更接近用户574632的方向,您可以设置一条电话线,当用户想要查找表达式时,用户可以通过该电话线给您打电话,因为您对文本了如指掌,你告诉他们表达式在页面中的位置。我不知道你在说什么。你应该考虑充分解释你的想法,而不是试图把它们浓缩成尽可能小的句子。我不知道你在说什么。你应该考虑充分解释你的想法,而不是试图把它们浓缩成尽可能小的句子。哇,这是一个相当巧妙的解决方案-我不知道存在这样的事情。非常感谢。有趣的是,你没有想到这一点,因为你在代码中使用了缓冲区。缓冲区可以嵌套对您来说是件好事,对吗?如果您对所有内容/页面的公共访问都满意,那么就可以了。或者,您可以花时间提出XML作为控制用户可以搜索的关键字的替代方法。我的想法是,最好显示您允许的内容,而不是搜索所有页面和文件夹,而不是显示您不允许的内容。哇,这是一个非常巧妙的解决方案-我不知道存在这样的事情。非常感谢。有趣的是,你没有想到这一点,因为你在代码中使用了缓冲区。缓冲区可以嵌套对您来说是件好事,对吗?如果您对所有内容/页面的公共访问都满意,那么就可以了。或者,您可以花时间提出XML作为控制用户可以搜索的关键字的替代方法。我的想法是,最好显示您允许的内容,而不是搜索所有页面和文件夹,而不是显示您不允许的内容。