I've been using the PHP short echo code but realised that it doesn't print out the return value from a method. That is, the following will work
<?= $my_variable ?>
<?php echo $my_object->get_value(); ?>
But this won't return anything
<?= $my_object->get_value() ?>
Why does calling a method that returns a value not print to the screen with the short hand?
In normal cases, it should work.
See and test:
<?php
class A {
public function a() {
return 1;
}
}
$a = new A;
?>
<?= $a->a() ?>
output: 1
So, I think your problem come with the get_value() method, it seems that the method does not return a printable value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With