English 中文(简体)
预示着相对通向绝对道路的道路。 (king?)
原标题:preg_replace() relative paths to absolute path. (Masking?)

我正试图说明如何在相对的道路上掩盖一条道路。 这是用于CSS档案的定制缩略语Im,需要绝对相关途径。

因此,我要在一份中央支助事务文件url(....../images/file.jpg >上说几句。 该档案存放在名录上:/application/module/assets/cs/theme.cs,这意味着国际空间站档案中的新途径需要/application/module/assets/images/file.jpg

现在说,在<代码>/申请/申请/插图/插图/插图纳美/塞克斯/插图s和链接././././././module/assets/images/image.jpg上,所取代的道路是

因此,我问,是否有一个冰口——我可以这样做:

str_replace( ../ ,  /path/to/file/ , $file);
str_replace( ../../ ,  /path/to/ , $file);
str_replace( ../../../ ,  /path/ , $file);

希望这样做是有意义的。

Regards,
Andrew

最佳回答

产生于另一个问题()。 PHP: How to resolution a relative url:PHP tip: 如何将URL转化为绝对的URL

我认为,你想要履行的职能是<代码>url_remove_dot_segments功能,该功能采用了一条加固的道路(例如:base / .$path,并将一个文本带上/,/>/

问题回答

在你的工作中,我也可以感觉到很多,但也许“亲爱”的功能是你的朋友。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...