如何使用PHP为特定的Div节添加html基址? [英] How can add html base URL for the particular Div section using PHP?

查看:90
本文介绍了如何使用PHP为特定的Div节添加html基址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < base href =http://www.w3schools.com/target =_ blank> 

如何使用php来为特定的div部分添加上面的基本网址



如果我有两个div部分



本节链接将与上面的基本URl链接一起使用

 < div> 
< a href =/ help>帮助< / a>
< / div>

本节链接将与网站一起使用URl链接

 < DIV> 
< a href =/ help>帮助< / a>
< / div>

我正在尝试使用简单的html dom从一些其他网站获取一些内容并将其粘贴到一个div部分有相关链接。这可以转换为直接链接,如/images/image.png为www.example.com/images/image.png。

div>

 < div class ='normalUrl'> 
< a href =/ help>帮助< / a>
< / div>

< div class ='otherBaseUrl'>
< a href =<?php print('http://some.otherwebsite.com');?> / help>帮助< / a>
< / div>

这是一种硬编码方式,只是为了说明最终结果如何实现。我相信你想让这个更通用,以适应你的目标。


<base href="http://www.w3schools.com/" target="_blank">

How can i add the above base URL for the particular div section using php like

If i have two div section

This section links will work with above base URl link

<div>
<a href="/help">help</a>
</div>

This section links will work with websites URl link

<div>
<a href="/help">help</a>
</div>

I'm trying "simple html dom" to fetch some content from some other website paste it under one div section that has relative links. That can be converted to direct link like "/images/image.png" to "www.example.com/images/image.png"

解决方案

<div class='normalUrl'>
    <a href="/help">Help</a>
</div>

<div class='otherBaseUrl'>
    <a href="<?php print('http://some.otherwebsite.com'); ?>/help">Help</a>
</div>

This is a hardcoded way just to show how the end result can be achieved. I'm sure you want to make this more generic to fit your goal.

这篇关于如何使用PHP为特定的Div节添加html基址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆