未定义的变量,但对我有用。调试通知
我在Elementor Addon中收到了调试通知。未定义的变量$ out,但对我有用。 我不知道我在做什么错。
伙计们,请帮忙!
非常感谢!
注意:
未定义的变量:在文件/applications/mamp/htdocs /...
private function content($content,$disp) {
foreach ($content as $item){
$img = tmaddon_bg_images($item['img']['id'],$settings['img_size']);
$title = $item['title'] ? '<span class="tm-title"><p>'.$item['title']. '</p></span>' : '';
$subtitle = $item['subtitle'] ? '<span class="tm-subtitle"><p>'.$item['subtitle']. '</p></span>' : '';
$label_text = $item['label-text'] ? '<span>'.$item['label-text']. '</span>' : '';
// $icon = $item['icon'] ? '<span class="item-icon"><i class="'.$item['icon'].'"></i></span>' : '';
$icon = $item['icon'] ? '<div class="read-more-btn link link--arrowed">
<svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="9 9 32 32">
<g fill="none" stroke="" stroke-width="1.5" stroke-linejoin="round" stroke-miterlimit="10">
<circle class="arrow-icon--circle" cx="25" cy="25" r="15.12"></circle>
<i class="arrow-icon--arrow '.$item['icon'].'"></i>
</g>
</svg>
</div>' : '';
$carcls = $disp == 'carousel' ? 'swiper-slide' : $disp;
$url = $item['url']['url'];
$ext = $item['url']['is_external'];
$nofollow = $item['url']['nofollow'];
$url = ( isset($url) && $url ) ? 'href='.esc_url($url). '' : '';
$ext = ( isset($ext) && $ext ) ? 'target= _blank' : '';
$nofollow = ( isset($url) && $url ) ? 'rel=nofollow' : '';
$link = $url.' '.$ext.' '.$nofollow;
$btn = $url ? '<a '.$link.' class="fullink"></a>' : '';
$out .= '
<div class="items '.$carcls.'">
<div class="item-wrap">
<div '.$img.' class="item-image lazyload">
'.$btn.'
<div class="label-text">'.$label_text.'</div>
<div class="item-content">
'.$icon.$title.$subtitle.'
</div>
</div>
</div>
</div>
';
}
return $out;
}
}
I get a debug notice in Elementor Addon. Undefined variable $out, but it works for me.
I can't figure out what I'm doing wrong.
Guys, please help!
Thanks a lot!
NOTICE:
Undefined variable: out on line 1077 in file /Applications/MAMP/htdocs/...
private function content($content,$disp) {
foreach ($content as $item){
$img = tmaddon_bg_images($item['img']['id'],$settings['img_size']);
$title = $item['title'] ? '<span class="tm-title"><p>'.$item['title']. '</p></span>' : '';
$subtitle = $item['subtitle'] ? '<span class="tm-subtitle"><p>'.$item['subtitle']. '</p></span>' : '';
$label_text = $item['label-text'] ? '<span>'.$item['label-text']. '</span>' : '';
// $icon = $item['icon'] ? '<span class="item-icon"><i class="'.$item['icon'].'"></i></span>' : '';
$icon = $item['icon'] ? '<div class="read-more-btn link link--arrowed">
<svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="9 9 32 32">
<g fill="none" stroke="" stroke-width="1.5" stroke-linejoin="round" stroke-miterlimit="10">
<circle class="arrow-icon--circle" cx="25" cy="25" r="15.12"></circle>
<i class="arrow-icon--arrow '.$item['icon'].'"></i>
</g>
</svg>
</div>' : '';
$carcls = $disp == 'carousel' ? 'swiper-slide' : $disp;
$url = $item['url']['url'];
$ext = $item['url']['is_external'];
$nofollow = $item['url']['nofollow'];
$url = ( isset($url) && $url ) ? 'href='.esc_url($url). '' : '';
$ext = ( isset($ext) && $ext ) ? 'target= _blank' : '';
$nofollow = ( isset($url) && $url ) ? 'rel=nofollow' : '';
$link = $url.' '.$ext.' '.$nofollow;
$btn = $url ? '<a '.$link.' class="fullink"></a>' : '';
$out .= '
<div class="items '.$carcls.'">
<div class="item-wrap">
<div '.$img.' class="item-image lazyload">
'.$btn.'
<div class="label-text">'.$label_text.'</div>
<div class="item-content">
'.$icon.$title.$subtitle.'
</div>
</div>
</div>
</div>
';
}
return $out;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
警告的原因是,当第一次使用
$ of
时,它是指自身:这说明字符串将字符串附加到
$ ut
。但是,由于$ out
从未初始化,因此尚不清楚该字符串应附加。要删除此警告,请在循环开始之前初始化
$ out
:The reason for the warning is that when
$out
is used for the first time, it refers to itself:This is saying to append a string to
$out
. But as$out
was never initialised, it is not clear to what the string should be appended.To remove this warning, initialise
$out
before the start of the loop: