2016-12-28 52 views
0

此代碼:

if( get_theme_mod('enable_content_background_color') && empty(get_theme_mod('content_background_image'))) { 
     $custom .= " .site-content { 
       background-image: none; 
      }"."\n"; 

觸發此錯誤:

Can't use function return value in write context in /home3/*******/public_html/*******/wp-content/themes/outliner/includes/styles.php on line 41

我不知道爲什麼?

+0

我認爲你的文件擴展名是錯誤的。它應該是styles.css.php –

回答

1

這裏的問題是empty()函數只支持變量。如果你看看PHP.net Doc for the empty method你會看到;

Note: Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.

您需要做類似的事情;

$contentBgImage = get_theme_mod('content_background_image');  
if(get_theme_mod('enable_content_background_color') && empty($contentBgImage)) { 
//code 
}