【发布时间】:2018-07-30 19:39:38
【问题描述】:
有一个警告:
警告:第 112 行 /home/procsi/galina3000.ru/wp-content/themes/memoir/epanel/custom_functions.php 中的非法字符串偏移 'alt'
警告:第 113 行 /home/procsi/galina3000.ru/wp-content/themes/memoir/epanel/custom_functions.php 中的非法字符串偏移“标题”
代码如下:
if ( function_exists('has_post_thumbnail') ) {
if ( has_post_thumbnail( $post->ID ) ) {
$thumb_array['use_timthumb'] = false;
$args='';
if ($class <> '') $args['class'] = $class;
if ($alttext <> '') $args['alt'] = $alttext;
if ($titletext <> '') $args['title'] = $titletext;
$thumb_array['thumb'] = get_the_post_thumbnail( $post->ID, array($width,$height), $args );
if ($fullpath) {
$thumb_array['fullpath'] = get_the_post_thumbnail( $post->ID );
if ($thumb_array['fullpath'] <> '') {
$thumb_array['fullpath'] = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $thumb_array['fullpath'], $matches);
$thumb_array['fullpath'] = trim($matches[1][0]);
}
}
}
如何解决?谢谢。
【问题讨论】:
-
你能把标题也写成英文吗?
-
$args是一个字符串。您已将其定义为带有$args='';的字符串,但您将其作为带有$args['title']等的数组进行访问。 -
@Variable,请不要为他人翻译帖子。他们需要自己能够做到。 meta.stackoverflow.com/questions/297673/…
-
@Don'tPanic 另一半已经是英文了,不知道不能翻译问题,会看的,谢谢(ツ)
-
@Variable 是的,在这种情况下这没什么大不了的,仅供参考。