0

我运行一个小型的专业古典音乐列表网站,并在 heredoc 中存储场地名称、地址、电话号码等(带有 html 标记),存储在外部 php 文件中。我所做的就是写:

芒果弦乐四重奏在

<?php echo $local_arts_centre; ?>

并且场地的详细信息都打印的很整齐。

我写了一个搜索工具,它搜索文本但不搜索变量,会找到短语“mango string quartet”,但不会找到“local 艺术中心”。

我搜索了网络和 PHP 书籍,但找不到解决方案。任何想法都将不胜感激。

4

3 回答 3

0

非常感谢您的回复。例如,我要做的是搜索音乐会列表的网页(显然非常简化)。

<div>

Thursday, 17 May 2012

The Mango String Quartet will be playing Beethoven, Tavener and Terry Riley at:

<?php echo $local_arts_centre; ?>

Concert starts at 7.30pm

Tickets £10.00

</div>

当我通过 html 进行搜索时,除了 heredoc $local_arts_centre 的内容(其中包含场地的地址、电话号码等)之外,所有的东西都被找到了。有没有一种解析heredoc的方法,它显然显示在网页上,但在搜索代码时却没有?

这并不是真正必要的,但如果有人可以在特定场地或特定城市搜索音乐会,这将很有用。

当然有一个解决方法,但它不是那么整洁。我想我可以写:

<?php echo $local_arts_centre; /* Local Arts Centre London */ ?>

这意味着将找到“本地艺术中心”和“伦敦”。

无论如何,感谢您到目前为止的建议,我已经在论坛上找到了很多想法。

于 2012-05-17T07:54:37.197 回答
0

我不知道我是否正确,但...

HTML 代码

<!-- list of music -->
<a href="somefile.php?music=happybirthday">Happy Birthday</a>
<a href="somefile.php?music=rockandroll">Rock and Roll</a>
<a href="somefile.php?music=raps">Raps</a>

在 somefile.php

    <?php
        // array for locations if just a few
        $locations = array("here and there", "ther eand here");
        // checking if the name 'music' has a value
        if (isset($_GET['music'])) {
            $music = $_GET['music'];
            // since we have the value of music, lets put some locations to them.
            switch ($music) {
                case 'happybirthday':
                    echo "The location is at " . $locations[0]; //hereandthere
                    break;
                case 'rockandroll':
                    echo "The location is at " . $locations[0]; //hereandthere
                    break;
                case 'raps':
                    echo "The location is at " . $locations[1]; //thereandhere
                    break;
                default:
                    echo "Please select a music"; // or something
            }
        } else {
            echo "Please select a music"; // or something
        }
    ?>
于 2012-05-15T08:18:43.100 回答
0

您正在寻找isset($var)

如果未设置变量比isset($var) == null.

在此处检查“isset”:http: //php.net/manual/en/function.isset.php

于 2012-05-15T07:58:10.507 回答