php - Codeigniter - return an anchor() from function -
probably newb question here, how return ci anchor() call within function. want "hide" button if variable set value. ci's url helper documentation: https://ellislab.com/codeigniter/user-guide/general/helpers.html
a pseudo example won't work (can't return url helper anchor('',''):
$prevavailcompid = 0; function hidebutton($prevcompid) { if($prevcompid == 0) { return anchor('/getcomps/getspecificcomp/'.$prevcompid , 'prev comp'); //i've tried return echo anchor(...) } } further down on page:
<div id="prevbtncontainer"><? hidebutton($prevavailcompid); ?></div>
you don't need return anchor() function. can use
updated code
public function test(){ ?> <h1>test h1</h1> <div id="prevbtncontainer"><?php $this->hidebutton(0); ?></div> <div id="1prevbtncontainer"><?php $this->hidebutton(1); ?></div> <?php } private function hidebutton($prevcompid) { if($prevcompid == 0) { echo anchor('/getcomps/getspecificcomp/'.$prevcompid , 'prev comp'); } } i've tested in codeigniter , working.