Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double underscore in cakephp 2.0

Tags:

php

cakephp

I thought double underscore always meant private function but what does it mean in cakephp 2.0 in such examples as this http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

For example

$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
like image 448
CodeCrack Avatar asked Feb 16 '12 21:02

CodeCrack


People also ask

What does double underscore mean in PHP?

Strictly speaking, it means nothing in PHP as it is not a pre-defined function. However, in many frameworks, like CakePHP, and other libraries the double underscore is a function used for translating strings based on the user's language/locale preference.

Which PHP functions that begins with double underscore?

PHP functions that start with a double underscore – a “__” – are called magic functions in PHP. They are functions that are always defined inside classes, and are not stand-alone functions.


1 Answers

The double underscore function in CakePHP handles localization. It's used when you want to translate your application by providing a string translation dictionary.

Cake PHP Book: Global Constants & Functions

See also Internationalization and Localization

like image 90
Tim Avatar answered Sep 28 '22 09:09

Tim