关于php动态链接
stackoverflow 用户您好,
我的问题是关于 php 动态链接创建的。
我尝试创建动态链接,例如;
<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>
我的问题从线路开始;
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"
但是,生成的html页面创建为这样的链接:
.http://localhost/codeigniter/galleryController/index/yoxview/gallery/sevgiliye/images/anneye10.jpg
.http://localhost/codeigniter/galleryController/index/yoxview/ gallery/sevgiliye/thumbs/anneye10.jpg
我的控制器名称“galleryController”和我的函数名称“index”和其他基本网址添加在 href 链接之前。
我想创建仅包含
yoxview/gallery/sevgiliye/images/anneye10.jpg
这个网址的链接。
我怎样才能做到这一点?
谢谢。
Hello stackoverflow users,
My problem is about php dynamic link creation.
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:
.http://localhost/codeigniter/galleryController/index/yoxview/gallery/sevgiliye/images/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.
I want to created link which contains only
yoxview/gallery/sevgiliye/images/anneye10.jpg
this url.
How can i achive this ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与您的代码无关,而是浏览器处理非绝对 URL 的函数。您没有在网址上输入
/
或http://example.com/path/to/page
类型“root”,因此浏览器正在获取该地址页面的外观(http://localhosthost/codeignitre/galleryController/index
)并将其添加到您的非绝对网址中。您必须使用
/yoxwview/gallery/etc...
(假设这是您服务器上的有效路径)。This has nothing to do really with your code, and is a function of how browsers process non-absolute urls. You've not put a
/
orhttp://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.You'll have to use
/yoxwview/gallery/etc...
instead (assuming that's a valid path on your server).你不能。即使您只在链接中放置相对路径,您的浏览器也将始终显示并访问完整的 URL。您需要弄清楚如何从当前页面到达所需的链接,必要时使用绝对路径或 URL。
You can't. Your browser will always show and access a full URL even if you only put a relative path in the link. 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.