SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot surelybwh's Avatar
    Join Date
    Mar 2005
    Location
    San Antonio
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What does _e do?

    I found this in a theme for a WP blog:
    PHP Code:
    <?php _e('Categories:'); ?>
    Is it supposed to do something? I can't see that it is doing much of anything.

  2. #2
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a function that is defined by WordPress. I forget where the _e function is defined, but it's somewhere in there. It's not a PHP default function or something... it's just something that WordPress uses.
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    echo

    The _e function is found in the l10n.php (localization) file.
    PHP Code:
    function _e($text$domain 'default') {
        echo 
    translate($text$domain);

    As you can see it "echoes" the string, but it allows for the text to be translated to other languages.

  4. #4
    SitePoint Zealot surelybwh's Avatar
    Join Date
    Mar 2005
    Location
    San Antonio
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Tipem & Mittineague.

    Wonderful name for a function - that's why I had trouble finding it...

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    function

    If you like that, check out the __ function. Does the same as _e except it returns the text rather than echo it.

  6. #6
    SitePoint Zealot surelybwh's Avatar
    Join Date
    Mar 2005
    Location
    San Antonio
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Too funny.

    Makes you wonder why they didn't use __t rather than translate...

  7. #7
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by surelybwh View Post
    Too funny.

    Makes you wonder why they didn't use __t rather than translate...
    It because those two functions are shortcuts for translate
    Easier to type _e & __ repeatedly in a template then remember translate.

    IMHO
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  8. #8
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I love shortcut functions like that. Though, when I do it, i define them all in their own php file, just for shortcuts, so if anyone has any questions as to what they are, its easy to find.

    Best example of shortcut ever? '$' in prototype.js for javascript....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •