php e() and h() functions?

前端 未结 13 1822
情书的邮戳
情书的邮戳 2021-02-03 19:06

I and lately I\'m seeing h() and e() functions in PHP. I have googled them, but they are so short that results don\'t give any idea of what they are. I

相关标签:
13条回答
  • 2021-02-03 19:55

    Likely the framework you're using is doing some escaping and has defined some short hands for htmlentities and htmlspecialchars or equivalents.

    I'd do a search on whatever framework you're using for "function h("

    0 讨论(0)
  • 2021-02-03 19:56

    http://book.cakephp.org/view/121/Global-Functions these are shortcut functions in cakePHP

    Many of them are deprecated in 1.3 so beware of using them yourself

    0 讨论(0)
  • 2021-02-03 19:56

    h() is global function in CakePHP. Documents about h() for CakePHP version 2.5.7 : http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#global-functions

    0 讨论(0)
  • 2021-02-03 19:56

    Laravel also use e() helper function to runs htmlentities over the given string.

    echo e('<html>foo</html>');
    
    // &lt;html&gt;foo&lt;/html&gt;
    

    documentation : https://laravel.com/docs/5.8/helpers#method-e

    0 讨论(0)
  • 2021-02-03 19:59

    As several readers have said, these are CakePHP-specific short-cuts. You can find them in the API docs at: here (for CakePHP 2.x)

    I think I read that some of these are going to be removed in 1.3, personally I never used e() as typing echo really doesn't take that much longer :)

    edit: e() is deprecated in 1.3 and no longer available in 2.0 see here

    0 讨论(0)
  • 2021-02-03 20:02

    If you are using a decent editor press ctrl and click on the function. It should take you to the function's declaration.

    0 讨论(0)
提交回复
热议问题