html - Fatal error: Can't use function return value in write context in views/stock/form.php on line 29
398
My code is working just fine in localhost , but when i upload it to the server, it show this error on spesific line. This is the 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 } ?> />
Answer
Solution:
That's because you are using
empty()
on thetrim()
function.Try
trim()
before passing the data to theempty()
function, Something like this:Also, if it was me, I recommend using a cleaner code:
Answer
Solution:
this might work
what I have done is changed your
to
Answer
Solution:
Try another approch:
Answer
Solution:
Simple Assign the value to new variable
value="<?= !empty($ne_variable=trim($row->item_name))? $row->item_name:'' ?>"