Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between php output statements

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you what are the relevant knowledge points about the differences between php output statements, detailed content and clear logic. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

Difference: 1, echo () and print () functions are used to output one or more strings, but echo does not return a value, which is slightly faster than print; 2, "print_r ()" function is used to display information that variables are easy to understand; 3, "var_dump" is used to display the structure information of one or more expressions.

This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.

What is the difference between php output statements

Echo has a deep understanding of echo, echo is a function

Echo function: outputs one or more strings to the browser

Echo return value: void has no return value

Echo, "it's a fine day today."

Output result:

Print function: output strings to browsers

Print return value: integer 1

The following example: print prints out the string, and echo prints out the return value of print.

Echo (print ("it's a fine day")

Output result:

Echo runs slightly faster than print because it does not return a value

Print_r () displays easily understandable information about a variable. If you give string, integer, or float, the variable value itself is printed. If array is given, the keys and elements will be displayed in a certain format. Object is similar to an array

For example

$a = [1, print_r 2, 3, 4,]; (a)

Output result:

Var_dump () displays structural information about one or more expressions, including the type and value of the expression. The array will recursively expand the value and show its structure by indentation.

For example:

B = array (1,2, array ("a", "b", "c")); var_dump ($b)

Output result:

For example:

$d = 3.1; $c = true; var_dump ($d, $c)

Output result:

These are all the contents of this article entitled "what are the differences between php output statements?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report