我有这段代码片段,它获取SVG图像的源代码并将其添加到HTML中:
<?php echo file_get_contents("assets/images/lightening.svg"); ?>我想要添加一个函数root();(我已经开始工作了),它位于起始路径,它告诉它站点的根目录在哪里(我在多个位置提升站点)。
我想要的是它的一个版本:
<?php echo file_get_contents("'root();'.assets/images/lightening.svg"); ?>任何帮助都将不胜感激。谢谢。
发布于 2015-11-05 20:09:22
取决于函数root()是否返回路径而不跟踪路径:
<?php echo file_get_contents(root() . "/assets/images/lightening.svg"); ?>或尾随斜杠:
<?php echo file_get_contents(root() . "assets/images/lightening.svg"); ?>https://stackoverflow.com/questions/33553809
复制相似问题