PHP | echo and print
- Sachin Pathak

- Nov 27, 2019
- 2 min read
Updated: Dec 2, 2019

We have seen echo statement quite frequently in PHP codes of previous articles.It is the most basic way for displaying output in PHP.
However, there are two basic ways to get output in
PHP:-
1- echo
2- print
PHP echo statement
In PHP ‘echo’ statement is a language construct and never behaves like a function, hence no parenthesis required. The end of echo statement is identified by the semi-colon (‘;’). We can use ‘echo’ to output strings or variables. Below are some of the usage of echo statement in PHP:
1- Displaying Strings: We can simply use the keyword echo followed by the string to be displayed withing quotes. Below example shows how to display strings with PHP:
<?php
echo "Hello,This is a display string example!";
?>
Output:
Hello,This is a display string example!
2- Displaying Strings as multiple arguments: We can pass multiple string arguments to the echo statement instead of single string argument, separating them by comma (‘,’) operator. For example, if we have two strings say “Hello” and “World” then we can pass them as (“Hello”,”World”). Below example shows how to do this:
<?php
echo "Multiple ","argument ","string!";
?>
Output:
Multiple argument string!
3- Displaying Variables: Displaying variables with echo statement is also as easy as displaying normal strings. Below example shows different ways to display variables with the help of PHP echo statement:-
<?php
//defining the variables
$text = "Hello, World!";
$num1 = 10;
$num2 = 20;
//echoing the variables
echo $text."\n";
echo $num1."+".$num2."=";
echo $num1 + $num2; ?>
Output:
Hello, World!
10+20=30
PHP print statement
The PHP print statement is similar to the echo statement and can be used alternative to echo at many times.It is also language construct and so we may not use parenthesis : print or print(). The main difference between the print and echo statement is that print statement can have only one argument at a time and thus can print a single string. Also, print statement always returns a value 1. Like echo, print statement can also be used to print strings and variables. Below are some examples of using print statement in PHP:
1- Displaying String of Text:
We can display strings with print statement in the same way we did with echo statements. The only difference is we can not display multiple strings separated by comma(,) with a single print statement. Below example shows how to display strings with the help of PHP print statement:-
<?php
print "Hello, world!";
?>
Output:
Hello, world!
2- Displaying Variables:
Displaying variables with print statement is also same as that of echo statement. The example below shows how to display variables with the help of PHP print statement:-
<?php
//defining the variables
$text = "Hello, World!";
$num1 = 10;
$num2 = 20;
//echoing the variables
print $text."\n";
print $num1."+".$num2."=";
print $num1 + $num2;
?>
Output:
Hello, World!
10+20=30



I saw some online discussions mentioning https://688x.br.com/, so I took a quick look to see how the site structures and presents its content. I didn’t dive into any specific features or services — I just spent a little time observing the layout, navigation, and how the main sections are organized. The overall structure seemed reasonably clear, with distinct areas for different types of information, which makes it easier to scan and understand the basics at a glance. When content is organized and labeled clearly like that, it’s generally straightforward to pick up the key points without getting confused.
Mình có tình cờ thấy nhiều người bàn luận về fly88 com khi nói về những nền tảng cá cược trực tuyến, nên cũng nổi hứng vào xem thử. Mặc dù không tìm hiểu quá kỹ, nhưng mình đã dành chút thời gian để quan sát cấu trúc và cách trình bày trên trang. Ấn tượng là giao diện khá gọn gàng, các mục được sắp xếp rất rõ ràng, dễ theo dõi. Với mình, chỉ cần nội dung được trình bày mạch lạc như thế thì đã đủ để hiểu được những thông tin cơ bản rồi.
Hôm trước mình có lướt qua mấy bài viết trước khi trận đấu diễn ra và thấy nhiều người đề cập đến kèo bóng đá trực tuyến như một nguồn thông tin nhanh chóng. Thế là mình cũng muốn tìm hiểu một chút về cách mà các trang này trình bày dữ liệu. Mình không chú ý quá nhiều đến từng con số, chỉ để ý cách bố trí và tổ chức các mục. Cảm giác là khi các thông tin được sắp xếp rõ ràng, dễ nhìn thì việc đọc lướt không bị rối mắt. Đối với mình, chỉ cần nội dung được trình bày mạch lạc như vậy là đã đủ để nắm bắt những thông tin cần…
Mình có lần thấy mọi người bàn tán về các nền tảng online và có nhắc đến https://789clubze.win/, nên cũng muốn vào xem thử cho biết. Mặc dù không đào sâu, mình chỉ lướt qua một chút để xem cách họ sắp xếp thông tin. Thấy giao diện được phân chia rõ ràng, các mục tách biệt dễ nhìn, nên lướt qua cũng không bị rối mắt. Với mình, như vậy là đủ để hiểu các nội dung chính.
Mình có lần theo dõi các bài phân tích trước giờ thi đấu thì thấy nhiều người nhắc tới tỷ lệ kèo nhà cái hôm nay như một cách tham khảo thêm thông tin trước trận, nên cũng tò mò tìm hiểu thử cách các trang tổng hợp dữ liệu này trình bày nội dung. Mình không đi sâu vào phân tích từng con số cụ thể, chỉ quan sát cách bố trí bảng tỷ lệ, cách phân chia các cột và cách cập nhật thông tin tổng thể. Cảm giác là khi các chỉ số được hiển thị rõ ràng, sắp xếp mạch lạc thì việc đọc lướt sẽ thuận tiện và dễ theo dõi hơn. Với mình, chỉ…