11
I was taking a look at the PHP Handbook on the variables. There I found an excerpt of code that left me with the "foot behind".
$täyte = 'mansikka'; // válido; 'ä' é um caracter ASCII (extendido) 228
I always see in tutorials for beginners in PHP affirmations that it is not a good idea to declare variables with accents and similar things. However, now in the PHP Manual I saw this variable $täyte
.
I decided to run a test ...
$usuário = 'Wallace';
$cidadão = 'Brasileiro';
$preferências = ['PHP', 'jQuery'];
print_r(compact('usuário', 'cidadão', 'preferências'));
var_dump($usuário);
... and I got that result:
Array
(
[usuário] => Wallace
[cidadão] => Brasileiro
[preferências] => Array
(
[0] => PHP
[1] => jQuery
)
)
string(7) "Wallace"
See on IDEONE that everything went right.
Another point I’d like to make is that when I was learning a little bit of java
, I saw a piece of code like this:
JButton botão = new JButton();
And that also worked correctly.
Questions
Is there any possible problem in declaring variables with accents (like
$joão
,$está_certo
,$é_array
) in relation to the PHP language?It is a common practice among programming languages not to use accented characters in the declaration of variables?
I could give you the answer, however I don’t have much time to elaborate, but first read the answer to this question, http://answall.com/questions/40893/time-of-processing-%C3%A9-affected-by-size-of-vari-names%C3%A1vel and after this article http://local.joelonsoftware.com/wiki/O_M%C3%Adnimo_absoluto_que_todo_development_de_software_absolutely,Positivamente_Precisa_Saber_Sobre_Unicode_E_Conjuntos_de_Caracteres%28Sem_Desculpas! %29, in conclusion I believe that the conversion of Bites could be interpreted differently. due to the fact that these are characters below 127.
– Guilherme Lautert
Thank you very much, @Guilhermelautert. I’ll give a read yes
– Wallace Maxters
http://answall.com/q/16555/91
– rray