Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Shorthand functions
  • i just found e() in the 404 view file and wasn't sure what it was. I also found __() and then saw that it was related to Lang class. Are there more of these? Are they documented somewhere? On the same topic is there a shorthand function for echoing variables in views. It seems that I use: <?php if(isset($content)) echo $content; ?> and maybe that e() function would take care of undefined variables? Just a thought... <?=e($content);?>
  • The only functions in Fuel are defined in the core/base.php file. Not yet documented though, I'll add an issue on Github about it. What you are trying to do can't be done by Fuel as you want error suppression, but as the variable is fetched by the parser before the function e() is called Fuel coulnd't suppress the error. Only language constructs like isset() and empty() can do that. I also think that would be mostly clutter, we have a strict no-procedural rule which we only broke for a very small number of function for practical reasons.
  • Would suppression be "smart" to use in views?
    <?php echo @$content;?>
    
  • It's considered bad, mostly because you're slowing down your app. The error may not be shown but it's still reported and it's still handled by the PHP parser, which is an incredibly inefficient process in comparisson to checking it using isset() and only using the variable when you've made sure.
  • Thanks! That's what I thought would be the case...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion