提取要在H1标记中使用的URL字符串

时间:2015-10-11 22:30:08

标签: php html

我有一个搜索结果页面,我想在其中使用搜索结果中的字符串填充H1标签。

网址: http://www.italianposters.net/posters.php?psps_search=piedmont+italy H1标签应为:意大利皮埃蒙特的印刷品和海报 理想情况下没有+号。

该页面包含由第三方(PopShops)提供的以下代码,如何添加代码以提取有问题的URL字符串以将其插入H1标签而不更改第三方代码的功能? :

`

        $psps_parameters = '';

        foreach ($_REQUEST as $key => $value) {
          if (strpos($key,"psps_") > -1 ) {
            $psps_parameters .= '&'.$key.'='.urlencode($value);
            $psps_base_url = str_replace('&'.$key.'='.urlencode($value), "", $psps_base_url);
            $psps_base_url = str_replace($key.'='.urlencode($value), "", $psps_base_url);
          }
        }  

        $psps_parameters .= "&psps_show_search=true";
        $psps_parameters .= "&psps_show_navigation=true";
        $psps_parameters .= "&psps_show_products=true";

        $psps_url = "?psps_base_url=".urlencode($psps_base_url);

        $psps_url="http://shops.popshops.com/shops/php/82lgg56w26ho16kiakj9li9m5$psps_url$psps_parameters";

        # Include the shop
        if (function_exists('curl_init')) {
        $shop=curl_init();
        curl_setopt($shop,CURLOPT_URL,$psps_url);
        curl_exec($shop);
        curl_close($shop);
          } else {
            readfile($psps_url);
          }
        ?>`

谢谢大家, 科尔

1 个答案:

答案 0 :(得分:1)

start'
    2015-10-11T23:35:09.396835+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in

ref1:http://php.net/manual/en/function.echo.php

ref2:http://php.net/manual/en/function.htmlspecialchars.php

ref3:http://php.net/manual/en/reserved.variables.get.php