A detailed explanation based on the difference between the comma and the dot number in PHP

Source: Internet
Author: User
The following small series for you to share a text based on the echo in PHP with a comma and the difference between the number of points, with a good reference value, I hope to help you. Let's take a look at it with a little knitting.

Examples are as follows:

<?php//point and comma test, involving the forced conversion of strings echo 1+5;echo "<br/><br/>"; Echo ' 1+5= '. " 1+5 "." <br/> "; Echo ' 1+5= '." 5+1 "," <br/><br/> "; Echo ' 1+5= ', 1," <br/> ";//comma, no space needed for Echo ' 1+5= '. 1, "<br/>";//with connector, need space, otherwise error echo ' 1+5= ', 100+200, "<br/><br/>"; Using commas, often used to output multiple variables, does not affect the output//omitted the string stitching step, theoretically in the echo when the "comma" will be faster. Replace with a connector, note that the following test: Echo ' attention! <br/> '; Echo ' 1+5= '. "<br/>";//note. And 100 need space between, otherwise error echo ' 1+5= '. "<br/>"; Echo ' 1+5= '. 100+200, "<br/>";//Here The result begins to be abnormal echo ' 1+5= '. 200+100, "<br/>"; Echo (' 1+5= ') +100, "<br/>"; As you can see from the results above, the connector takes precedence over the operator echo "<br/>";//First Look at the forced conversion of the string echo (int) ' ABC1 '; echo "<br/>"; Echo (int) ' 1ABC '; echo "<br/>"; Echo (int) ' 22ABC '; echo "<br/><br/>";//Result: cast a string into a number, PHP will search for the beginning of the string,// If the beginning is a number then the conversion, if not directly return 0.//back to the question of the test echo ' result analysis: '; Echo ' 1+5= '. 100+200, "<br/>"; */* program is executed in this way, * First connect ' 1+5= '. 100 The result is the string ' 1+5=100 ', * then perform the operation, the string to be operated with the number will be cast by the system, the string ' 1+5= 100 ' converted value is 1, * last 1 +200=201. */* with commas why not? The manual says: The comma is multiple parameters. That is, multiple parameters, in other words, Commas are separated by the equivalent of n parameters. That is, ECHO is used as a function, so echo will calculate each parameter first, and then output separately, so we do not have the above problem with commas */?>

The results are as follows:

The above based on the echo in PHP and the difference between the comma and the dot is a small part of the whole content to share to everyone, I hope to give you a reference, but also hope that we support PHP Chinese network.

Articles you may be interested in:

Example of PHP implementation of the 1 number algorithm in statistical binary

PHP Development with remote control server for the relevant explanation

A detailed description of how the CI framework (CodeIgniter) operates with Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.