0
重定向後有一種方法可以繼承變量嗎?重定向後變量PHP
例如在projects.php
foreach ($projects as $key=>$project) : ?>
<li class="">
<a href="<?= root_url('project/'.$project->url_title) ?>/" title="<?= $project->name ?>">
<? if (isset($project->images[0])) :
$thumb_image_path = $project->images[0]->getThumbnailPath(310, 276, true, array('mode'=>'fit'));
else :
$thumb_image_path = '//placehold.it/320x285/ffffff/000000';
endif ?>
<? // echo $thumb_image_path; ?>
<img src="<?= $thumb_image_path ?>" alt="<?= $project->name ?>">
<div class="caption">
<h4><?= $project->name ?></h4>
<h5 class="hide-for-small-only">Not dynamic</h5>
<p class="hide-for-small-only"><?= $project->description ?></p>
</div>
</a>
</li>
<? endforeach ?>
當重定向到項目/ nameoftheproject,是有辦法仍然可以訪問變量$項目?所以,我可以用它做$項目 - >標題
謝謝您的回答
將它填入會話中,或通過cookie或查詢字符串發送它。 –
會話或cookie將是最佳選擇。將對象壓縮到查詢字符串中會很麻煩。 – greydnls