PHP Tutorials 3: PHP Print “How to Print” and Descriptions

PHP Tutorials 3: PHP Print “How to Print” and Descriptions

In the previous sections we learned; how to create a localhost or local server to test our PHP codes and a platform to write PHP codes. In this section we are going to learn about; how to print data on the screen? (php print) and description methods.

See Also: PHP Tutorial 2: First PHP Project

As previous section open sublimetext3 create a new file and save with vars.php name inside the PHP3 in the WampServer’s root folder (www) folder (as mentioned previously). This way you can access the file through: http://localhost/php3/vars.php

Print Command in PHP (PHP Print):

There are different commands for printing strings or anything else in PHP. The most prevalent way or command to print data in PHP is the same as we used in the last section “echo”. It has a simple syntax as below:

Ex: Below code will print “Hello, this is codejow with free PHP Tutorials.”.

HTML’s codes can be shown out on the browser with echo command inside the double quotes as texts or strings are needed to be inside double qoutes.

Check coming codes:

php print

As you can see in the picture, echo can print everything put in front of it even HTML codes. HTML tags will be printed as well if they are put inside single quote, so if you want HTML tags to work; don’t put them inside single quotes. This was all about php print with “echo” command.

Writing Descriptions inside PHP codes:

Developers of almost all languages put some descriptions with their codes; in-order to understand the codes easily on the next visit. Keep in mind that descriptions are visible to coders and developers only and are not printable.

Let’s do some example:

In the same file (vars.php) below the written echo command and above the php ending tag (?>), put or write the below codes and go to your browser and refresh the page.

As you see the above codes; There are three kinds of comments or description types. Two single-line comment and a multi-line comment.

Next we’ll learn about variable; keep following codejow

 

Previous What is a Function in Programming Languages? (Examples in C++)
Next CPP Tutorials: Classes in C++ and OOP Concept

About author

Raza Bayani
Raza Bayani 44 posts

Raza Bayani studies BCE (Bachelor in Computer Engineering) in Poly-technical University of Kabul. He is the CEO of CODEJOW group, a web designer, coder and recently a blogger. Raza thinks, he can help others and also boost-up his own programming skills being on codejow.com.

View all posts by this author →

You might also like