been a while....
what does __() do? I assume it returns whatever string is in the parens, but I can't be sure until someone here tells me it is
so <?=__('Add')?> returns the string Add?
I couldn't find this in the manual.....
been a while....
what does __() do? I assume it returns whatever string is in the parens, but I can't be sure until someone here tells me it is
so <?=__('Add')?> returns the string Add?
I couldn't find this in the manual.....
Never heard of it...
What's wrong with <?php echo "Text"; ?> ???
where did u come across <?=__('Add')?>
???
reg
kevin
mmm... just noticed another file....
$__ = Array(.....)
so now I'm not confused in one thing, but yes in another!
can the $ be dropped when using <?= to display a string???
the code uses <?=__('Blabla')?>....
I think that the __('text') is a function call, which may work something like this:
<html>
<body>
<pre>
<?php
$__ = array('foo','bar','three'=>'quux');
function __($key) {
global $__;
return $__[$key];
}
print_r($__);
?>
<hr />
<?='one ','two ',__('three'),' ',$__['three']?>
</pre>
</body>
</html>
The <?= ... ?> construct is just a shortcut for the echo statement. Any comma separated list of expressions is allowed there. Look through your source code for a function named __
ok... just so none of you have an aneurism wondering about what the hell this __ thing is... let me explain whats up and why I'm still confused.
I'm using some closed source php code, so I don't know all the constants and functions, nor can I find out. All I understand is that I found a file in ..../languages/template which contains an array:
$__ = Array(
'Add' => 'Add',
'Delete' => 'Delete',
....
....
....
)
and thats it. now back in the file I was editing there are labels that I assume are meant to change if the language changes, so having an array like that seems like a logical thing to do. However, when retrieving the values of words in the array, the $ is omitted, yet the value is still displayed:
<?=__('Add')?>
how is this possible???
I do know that _() is an alias of gettext(), but that's only 1 underscore.
Maybe the original coder is trying to emulate $_ as in Perl?
The double underscores confuse me though, it seems that whoever was coding was trying to be esoteric about it.
Originally posted by epimeth
ok... just so none of you have an aneurism wondering about what the hell this __ thing is... let me explain whats up and why I'm still confused.I'm using some closed source php code, so I don't know all the constants and functions, nor can I find out. All I understand is that I found a file in ..../languages/template which contains an array:
You can find out all the constants and functions. See get_defined_functions() and get_defined_constants()
Closed source - that's the key:
<?php
function __($foo)
{ echo "This function has a deliberately hard-to-pronounce name. And no, it's not $foo.";
}
__('Barry White');
?>
I recon somewhere in index.php is an include that pulls in whatever is in the language folder (thats where I found the $ array) and makes a bunch of constants based on the $ and makes them just __... whatever... as long as it works :-)