[英]Declare a php constant within a php variable
我有以下代码:
<?php $background_holder = echo get_bloginfo('template_directory');'/images/banner.jpg';?>
background-image: url("<?php echo get_theme_mod('header_background_image', $background_holder;); ?>");
我正在尝试为$background_holder
设置一个常量,然后将其添加到背景图像变量中。 我敢肯定我写的东西有些不对劲,但是目前没有任何作用。
$background_holder
只是您要为其分配变量的变量,无需echo
。 此外,似乎您正在尝试将'/images/banner.jpg' to some base directory. If this is the case, you'd need to use the concatination operator (
'/images/banner.jpg' to some base directory. If this is the case, you'd need to use the concatination operator (
.`):
<?php $background_holder = get_bloginfo('template_directory') . '/images/banner.jpg';?>
background-image: url("<?php echo get_theme_mod('header_background_image', $background_holder); ?>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.