Magento tips

Php echo and print statements

There are two fundamental ways to get output with PHP: echo and print. Echo and printing are more or less identical. Both are used to output screen data. The differences are small: echo does not have a return value while print has a return value of 1 so that it can be used in terms. Echo may take multiple parameters (although rare) while printing may take one argument. Echo is slightly faster than printing.

The PHP echo Statement

One or more strings can be output from the echo statement. Generally speaking, the echo statement can display anything that can be displayed to the browser, such as string, numbers, variables, expressions results, etc. Since echo is a language construct that is not actually a function (like ‘if’ statement), it can be used without parentheses, e.g. echo or echo). If you want to pass more than one parameter to echo, however, you must not include the parameters within parentheses. Instead of a single string reasoning, we can transfer various string statements to the echo declaration and separate them by comma (', ') operator. For instance, if we have two strings that say "Hello" and "World," we can pass them as ("Hello,""World")

The PHP print Statement

You can also use the print statement to display output to the browser (an alternative to echo). Like echo, printing is not a real function, but a language construct. Without parentheses like: print or print), (you can also use it. Both the echo statement and the print statement work the same way except that the print statement can only output one string and always return 1. That's why the echo statement was considered marginally faster than the print statement as it returns no value. In the same manner we did with echo statements, we can show strings with print declaration. The only difference is that with a single print statement, we cannot show various strings distinguished by comma,). The instance below demonstrates how to use PHP print declaration to show strings. Thanks to custom php application developmentthis is possible.

Last article.

Les publications similaires de "Developper blog"

  1. 18 Sept. 2020The experts in terms of Php devlopment are SimplyPhp100 vues
  2. 15 Août 2020Only the best standard of Php development will do183 vues
  3. 20 Juil. 2020Hiring the right standard of quality352 vues
  4. 20 Juin 2020The steps to become a top Php programmer455 vues
  5. 6 Mai 2020Do you know Array in PHP?634 vues
  6. 19 Avril 2020Hire us ! We have the solutions you require !659 vues
  7. 17 Mars 2020We propose PHP shopping cart software743 vues
  8. 15 Fév. 2020Php script for ecommerce933 vues
  9. 22 Janv. 2020A magneto developer on par with your demands866 vues
  10. 16 Nov. 2019A company adapted to your needs : SimplyPhp.com1124 vues
  11. 20 Août 2019Server side scripting language for a Php programmer1344 vues
  12. 26 Mars 2019Knowing your frameworks with Magneto1802 vues
  13. 22 Déc. 2018What companies look for in Php programmers2203 vues
  14. 16 Nov. 2018Tips and hacks on how to be an Php expert2247 vues
  15. 18 Oct. 2018Design and development skills needed to excel in Php2161 vues