未定义的变量:name_tags(视图:C:\ xampp \ htdocs \ portofolio \ resources \ views \ content.blade.php)

时间:2019-04-28 05:54:29

标签: php laravel

我遇到below错误:

  

未定义变量:name_tags(查看:   C:\ xampp \ htdocs \ portofolio \ resources \ views \ content.blade.php)

代码:

<?php $currentLoopData = $artikel->tags;
$env->addLoop($currentLoopData); 
foreach($currentLoopData as $d):
    $env->incrementLoopIndices();
    $loop = $env->getLastLoop(); ?>
    <small><?php echo e($d -> $name_tags); ?></small>
<?php 
    endforeach; 
    $env->popLoop(); 
    $loop = $env->getLastLoop();
?>

我的数据库:

1 个答案:

答案 0 :(得分:0)

使用$d->name_tags代替$d -> $name_tags

您的代码应如下所示;

<?php $currentLoopData = $artikel->tags;
$env->addLoop($currentLoopData); 
foreach($currentLoopData as $d):
    $env->incrementLoopIndices();
    $loop = $env->getLastLoop(); ?>
    <small><?php echo e($d->name_tags); ?></small>
<?php 
    endforeach; 
    $env->popLoop(); 
    $loop = $env->getLastLoop();
?>