PHP echo print question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

PHP echo print question

Can somebody explain me why echo print(1) gives 11?

23rd Jul 2017, 12:45 AM
Danil Dots
Danil Dots - avatar
4 Answers
+ 3
Simple if echo 1; outputs 1 and print 1; outputs 1 then echo print 1 outputs 11 (1 twice)
23rd Jul 2017, 12:52 AM
Infant Raj
Infant Raj - avatar
+ 2
I understand this is because each have their own place and situations where they are useful check this link for more https://stackoverflow.com/questions/234241/how-are-echo-and-print-different-in-php
23rd Jul 2017, 1:02 AM
Infant Raj
Infant Raj - avatar
0
@Infant Raj thanks, it was just a bit confusing because of one printing command inside another...
23rd Jul 2017, 12:58 AM
Danil Dots
Danil Dots - avatar
0
now it is clear :) thanks @Raj
23rd Jul 2017, 1:07 AM
Danil Dots
Danil Dots - avatar