Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I declare a function name "_"?

Tags:

Code:

function _() {     echo 'hello word'; } 

Output:

Fatal error: Cannot redeclare _()

I haven't defined this function _ before, then why I am getting this error?

like image 764
John K Avatar asked Aug 21 '11 13:08

John K


People also ask

What does _ mean in Python function?

Python automatically stores the value of the last expression in the interpreter to a particular variable called "_." You can also assign these value to another variable if you want. You can use it as a normal variable.

What does _ mean in JavaScript function?

Updated on July 03, 2019. The dollar sign ($) and the underscore (_) characters are JavaScript identifiers, which just means that they identify an object in the same way a name would. The objects they identify include things such as variables, functions, properties, events, and objects.

What is difference between _ and __ in Python?

Enforced by the Python interpreter. Double Leading and Trailing Underscore( __var__ ): Indicates special methods defined by the Python language. Avoid this naming scheme for your own attributes. Single Underscore( _ ): Sometimes used as a name for temporary or insignificant variables (“don't care”).

Why do some Python functions start with _?

A single leading underscore in front of a variable, a function, or a method name means that these objects are used internally. This is more of a syntax hint to the programmer and is not enforced by the Python interpreter which means that these objects can still be accessed in one way on another from another script.


1 Answers

_() is an alias for gettext.

like image 164
deceze Avatar answered Oct 09 '22 12:10

deceze