rss

About Me

My Photo
irnanto dwi saputra
View my complete profile

24 September 2011

Using the Echo or Print

Hello, this time I will try to discuss two functions that we often use, ie, echo and print, we made dizzy sometimes between two options, using echo or print when you want to display the contents of a variable, or just display as plain text alerts of a process that has been done. Echo or Print? Echo or Print? Echo or Print? and so on ... A little confused indeed.

In addition to print php echo and also provides many alternatives for the syntax of another, different function but the task remains the same, plus dizziness, more confused.

The author himself is quite confused to choose one of them, echo or print? echo or print? but after studying the various existing CMS like joomla, drupal, wordpress, it turns out they are the web developers tend to use echo rather than print, then what is the reason?

Let us go into. Php language a developer ever do the testing, and the result is the echo is 15% faster process than the print function (in millisecond). And it is common knowledge that if the print is a function that returns the value in it (returning value). And there is another reason why most developers prefer to use echo rather than print, another reason is, time efficiency, because the echo was only requires 4 letters to be typed, while the print it has 5 letters to be typed. But this is reality. A lazy programmer to write the letter 't'. And this has become a natural human instinct, choose a shorter. Still the same.

Okay, for further efficiency is the use of:
echo "$ variable1 and". "$ Variable2 to be displayed". "Put here";

it takes a lot of resources, because the dot has a function to mengadd / add the contents of a variable, instead of connecting or forwarding. The difference between adding a forward is like this:

Adding it to have meaning, opening up a new variable and then add the contents into the variable, then closes the variable. While the connect or continue to have meaning, its variable was content to continue living variablenya opened. Adding consists of three processes, while connecting or meneruskaan just doing one process.

Good use of echo is as follows:
echo $ variable, "and", $ variable2, "which will be displayed", "put here";

I separate each word here only as a simulation of actual cases. Echo is good it's not use a dot to connect each variable, or display text, but use a comma. So the process is faster, and fewer and fewer resources required.

Read also this....



0 komentar:


Post a Comment

 

Site Info

Google Pagerank Powered by  MyPagerank.Net My Ping in TotalPing.com TopOfBlogs My Zimbio Blog Directory