PHP链接无法正常工作

时间:2017-08-09 11:23:09

标签: php hyperlink

我将图像悬停在php页面上,该图像应该链接到某个URL。

if(file_exists($actionsloaded)) 
    echo '<a href=\"index.php\"><img src="/wp-content/uploads/2017/07/'.$image_on.'" onmouseover="this.src=\'/wp-content/uploads/2017/07/'.$image_off.'\';" onmouseout="this.src=\'/wp-content/uploads/2017/07/'.$image_on.'\';"/></a>';
else

问题是,当我点击链接时,它会转到url.com/"index.php/"

任何想法可能有什么问题吗?

2 个答案:

答案 0 :(得分:2)

删除HeaderHandler上的\。我已经解决了,您可以使用此代码

href

如果echo '<a href="index.php\"><img src="/wp-content/uploads/2017/07/'.$image_on.'" onmouseover="this.src=\'/wp-content/uploads/2017/07/'.$image_off.'\';" onmouseout="this.src=\'/wp-content/uploads/2017/07/'.$image_on.'\';"/>asdf</a>' $image_on=10;则此代码会显示在浏览器

$image_off =20;

答案 1 :(得分:1)

您shuld删除所有引用转义并查看以下更新的代码。

if(file_exists($actionsloaded)) 
    echo '<a href="index.php"><img src="/wp-content/uploads/2017/07/'.$image_on.'" onmouseover="this.src='/wp-content/uploads/2017/07/'.$image_off.'';" onmouseout="this.src='/wp-content/uploads/2017/07/'.$image_on.'';"/></a>';
else