简体   繁体   English

关于PHP动态链接<a href=“”></a>

[英]about php dynamic link <a href=“”></a>

Hello stackoverflow users, 您好stackoverflow用户,

My problem is about php dynamic link creation. 我的问题是关于php动态链接的创建。

I try to create dynamic link like; 我尝试创建类似的动态链接;

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="tr" xml:lang="tr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9" />
        <title>Dilşad Çiçekçilik</title>    

        <script type="text/javascript" src="yoxview/yoxview-init.js"></script>

    </head>
    <body>
        <div class="yoxview">
          <?php 

          ...

          for($i=0;$i<$images->num_rows();$i++) {
              echo "<a href='".$imagesArr[$i]."' ><img src='".$thumbsArr[$i]."' /></a>";
          } 

          ....

          ?>
          <?php echo $this->pagination->create_links(); ?>
        </div>
    </body>
</html>

my problem start from the line; 我的问题从一线开始;

echo "<a href='".$imagesArr[$i]."' ><img src='".$thumbsArr[$i]."' /></a>";


$imagesArr[$i] contains the url -->"yoxview/gallery/sevgiliye/images/anneye10.jpg"

$thumbsArr[$i] contains the url -->"yoxview/gallery/sevgiliye/thumbs/anneye10.jpg"

But, generated html page created to link like this: 但是,生成的html页面创建为像这样链接:

.http://localhost/codeigniter/galleryController/index/yoxview/gallery/sevgiliye/images/anneye10.jpg .http://localhost/codeigniter/galleryController/index/yoxview/gallery/sevgiliye/images/anneye10.jpg

.http://localhost/codeigniter/galleryController/index/yoxview/gallery/sevgiliye/thumbs/anneye10.jpg .http://localhost/codeigniter/galleryController/index/yoxview/gallery/sevgiliye/thumbs/anneye10.jpg

my controller name "galleryController" and my function name "index" and other base url are adding before the href link. 我的控制器名称“ galleryController”和我的函数名称“ index”以及其他基本网址都添加在href链接之前。

I want to created link which contains only 我想创建仅包含链接

yoxview/gallery/sevgiliye/images/anneye10.jpg yoxview / gallery / sevgiliye / images / anneye10.jpg

this url. 这个网址。

How can i achive this ? 我怎样才能做到这一点?

Thank you. 谢谢。

This has nothing to do really with your code, and is a function of how browsers process non-absolute urls. 这实际上与您的代码无关,并且是浏览器如何处理非绝对URL的功能。 You've not put a / or http://example.com/path/to/page type "root" on your urls, so the browser is taking the address of the page as it sees it ( http://localhosthost/codeignitre/galleryController/index ) and adding that to your non-absolute urls. 您没有在URL上放置/http://example.com/path/to/page类型“ root”,因此浏览器将按照看到的页面地址进行访问( http://localhosthost/codeignitre/galleryController/index ),并将其添加到您的非绝对网址中。

You'll have to use /yoxwview/gallery/etc... instead (assuming that's a valid path on your server). 您必须改用/yoxwview/gallery/etc... (假设这是服务器上的有效路径)。

You can't. 你不能 Your browser will always show and access a full URL even if you only put a relative path in the link. 即使您仅在链接中放置相对路径,您的浏览器仍将始终显示并访问完整URL。 You will need to figure out how to get from the current page to the desired link, using an absolute path or URL if necessary. 您将需要弄清楚如何从当前页面转到所需的链接,必要时使用绝对路径或URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM