在php中的链接后附加变量

时间:2016-03-24 23:20:09

标签: php variables hyperlink append vbulletin

我正在尝试附加我的链接后显示计数的变量,但我已经有了代码我需要替换链接以将它们重定向到重定向页面。

这是我目前的代码:

$this->post['message'] = str_replace('href="', 'href="./out.php?link=', $this->post['message']);
$this->post['signature'] = str_replace('href="', 'href="./out.php?link=', $this->post['signature']);

所以所有链接都被重定向到out.php

(小小的附加问题我怎么能让这不影响img href?)

回到主题,我要做的是在链接后添加$ someVariable [value],也不会影响图像。

该变量将显示纯文本(数字) 例如,最终结果如下:

<a href="./out.php?link=http://google.com">Google</a>(##)

其中##代表$ someVariable

DOM让我感到困惑,我无法想到其他任何方法,所以我需要一些帮助。

1 个答案:

答案 0 :(得分:1)

1

$ur = "./out.php";
$k = str_shuffle("7dfg9bf09cv04e79507e197a1dtdy8j3");
$web = $ur."/?link=".$k;
echo $web;

这是一个例子。

2

Escaping quotation marks in PHP

<?php 

$ur = "./out.php";
// $k = $this->post['message'];
$k = "hello";
$web = "/?link=".$k;
$li = "<a href=\"".$ur.$web."\">".$k."</a>(".$k.")";
echo $li."\n";
?>