I am just wondering how Echo and Print are different.
I gather that they are both used to output results, but is one more apt for a particular situation than the other?
EDIT: While I have you guys here, maybe you can explain the difference between $_POST and $_GET
Print always returns 1 (true) and can accept only one parameter, whereas echo doesnât return a value and can accept multiple parameters that are then concatenated together.
lol âŚand read many times âŚjust remembering that
to addâŚprint is function and echo is language constructâŚ
(type of ?s that are asked in zend certificationâŚ)
Theyâre both language constructs actually. They donât require parenthesis, and in fact when using print() in a conditional statement, using parenthesis for the print statement is likely to cause problems.
I agree that it was an unfair characterisation that I made against the print statement. It would be fairer to say that in my opinion, the echo statement is the more useful of the two on a day-to-day basis.
Be aware that with both methods a query string is passed. The only real difference (one that php doesnât highlight) is that POST and GET actually have meaning in http.
The actual difference between GET and POST is that with GET the browser is allowed to assume that if it does multiple calls passing the same value that the same result will be returned whereas with POST the assumption is that the data on the server may be updated and so a second identical call may return different results.
ok seems like that book note was wrong âŚ
any way i found this
Note: The print() function is not actually a function, so you are not required to use parentheses with it.
Tip: The print() function is slightly slower than echo().
print() function is not a function sound whimsical but true
And the speed difference is even greater when you use echo with comma-separated strings, as opposed to concatenated strings. But even so, such minor speed situations are not the reason to use echo.
My favorite part of that post is that at the beginning, theyâre printing/echoing âHello Worldâ, but when they move to concatenation, they completely cut the spaces out of the equation, and are echoing âHelloWorld<br>â.