繁体   English   中英

带有params和php realpath的路径

[英]Path with params and php realpath

在合并多个CSS的过程中,需要将相对路径转换为绝对路径。

步骤之一-获取真实路径。

Bootstrap及其CSS:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
       url('../fonts/glyphicons-halflings-regular.woff') format('woff'),
       url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),
       url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

realpath之后的结果:

@font-face {
    font-family: "Glyphicons Halflings";
    src: url("/somepath/fonts/glyphicons-halflings-regular.eot");
    src: url("") format("embedded-opentype"),
         url("/somepath/fonts/glyphicons-halflings-regular.woff") format("woff"),
         url("/somepath/fonts/glyphicons-halflings-regular.ttf") format("truetype"),
         url("") format("svg");
}

对于带参数的路径,返回false

如何获取带参数的路径的真实路径并保存参数

您是说php函数“ realpath”吗? 如果是这种情况,则不是要在url上使用,而是要在文件系统路径上使用。

如果要为字体使用绝对路径,则应以“ /”开头。 即:url(“ / css / fonts / glyphicons-whateveryoulike.ttf”)

开头的“ /”将是您的Web目录的根目录。

暂无
暂无

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

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