html - Fatal error: Can't use function return value in write context in views/stock/form.php on line 29 -
my code working fine in localhost , when upload server, show error on spesific line. error line of code.
<input type="text" required="required" name="i_name" class="form-control" placeholder="masukkan nama item..." <?php if(!empty(trim($row->item_name))){ ?> value="<?= $row->item_name ?>"<?php } ?> />
that's because using empty()
on trim()
function.
try trim()
before passing data empty()
function, this:
<?php $item_name=trim($row->item_name); ?> <input type="text" required="required" name="i_name" class="form-control" placeholder="masukkan nama item..." <?php if (!empty($item_name)) { echo 'value="' . $row->item_name . '"'; } ?> />
also, if me, recommend using cleaner code:
<?php $item_name=trim($row->item_name); $value=''; if(!empty($item_name)){ $value='value="'.$row->item_name.'"'; } ?> <input type="text" required="required" name="i_name" class="form-control" placeholder="masukkan nama item..." <?=$value;?> />
Comments
Post a Comment