![]() |
Tired of Print - (Just an idea lol)
PS: i know, I have to much time on my hands haha
Print, Got Owned ;) PHP Code:
Quote:
-Cf |
Hehe. Nonsense! But perhaps we can evolve this thread into something a little more meaningful :-)
I used to wrap a lot of my items in functions. For $_GET I used to have g(), $_POST was p(), and $_GET/$_POST was gp(). These are all fine and dandy but they don't describe too well what is happening inside that function. Whether it's setting or getting, what it's setting or getting.I was working with the open-source eCommerce system, Magento, a couple of weeks ago now, and I noticed, much to my disgust, that they were using function names with two underscores ( __) to print labels. What were they thinking?For instance: php Code:
As it is, however, I much prefer the use of print and echo. They describe well what is happening, and in themselves they are not functions, but rather language constructs. Wrapping them in functions, insofar as I see, isn't preferable, particularly in terms of readability.In addendum, I even dislike using printf , especially in amongst echoes and prints, because, from a superficial perspective, they are highlighted differently in Zend Studio, and the printf requires the items to be passed as arguments, unlike print and echo. It creates a mess!I now always follow the rule that everything must describe, as best as they can, what its purpose is. |
Thanks for the comment. ;) // always so insightful :)
and hum Magento a (__) thats yeah hum.. maybe a typo XD how epic would that be if it was a typo hehe.. |
jeje, solia hacerlo todo el tiempo con java para hacer el System.out.println() corto a println() pero con php no es tanto escribir print o echo, ademas de que me gusta el sintaxis de concatenar con comas en la declarativa de echo.
Nota Personal: Buscar otra alternative de eCommerce y no usar magento. jaja Translation: Quote:
Translation Added - By: CodeFreak |
it's quite funny, I recently had a system on my desk which also used __ for printing. But that stuff went through an translation system later on.
|
I like p() better than __() at least it refers to printing somewhat. :P
is echo/print too long to use? P.S. my bad :P The weird thing is that originally I wrote it in English then translate it to Spanish. I must of thought to be in another forum. Thanks for the translation CodeFreak, I didn't know you know Spanish. |
Tony, i am a person with many talents ;)
|
I am going to agree with wildhoney, its nice to make it shorter to type however there is still the issue of remember what letter stands for what.
|
Quote:
Code:
//bad assignment |
WordPress has a __() function. I forget the details but if you said __('Archives') the word archives would be translated into the visitors language. I don't know why the whole site wasn't wrappped by default but whatever
|
well... the __() function is more a gettext function, for i18n, wordpress has this function to return translated strings.
Wordpress also wrap echo __('some text') in _e('some text') I guess creating "shorcuts" is a good idea when you have to repeat a lot of preoccesses over and over again, but in other hand, creating your "own language" is not a good idead, at least your developing a framework :P |
| All times are GMT. The time now is 09:56 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0