PHP Tutorials from Scratch - Part 1 - Introduction - PHP editor, Adding comments, Print and Echo commands

Yepkoo

Yepkoo
Staff member
Friends, there is an important note that I would like to point out before starting the lessons. As the subjects progress, the lessons may seem a bit complicated so don't memorize the codes, you definitely don't need it right now, you can always use copy and paste, all you need to know is what the purpose of these codes is and where you should use them.


1- PHP first lesson
  • Required Programs
  • PHP Tag Opening and Closing
  • PHP interprete
  • Printing our first word on the screen


a- First of all, if you don't have an editor to write your PHP code, I can recommend the free Notepad++ program.

b- Your server checks the extension of your file and the PHP tags in it for a file to be interpreted as php.
Your file extension must be php. (For example myphpfile.php)

Second, you need to open and close PHP tags. The tag should be opened and closed as in the example. We can write any PHP code we want between these tags.

PHP:
<?PHP
 // We write the php codes between these tags.
?>

c- PHP interpreters allow us to add our own comments between our php codes to take notes or not to forget.
// sign is used for a single line comment.
For multi-line comments, /* */ signs are used and we write our comments between these signs.

PHP:
<?PHP
 // single line comment

    /*
   Multi-line comment test.
   line 1
   line 2
   As you can see the comments turned out to be a different color.
   This form of comment is the same in CSS and Javascript.
    */
?>

d- Finally, we can print text on the screen with "echo" or "print" code with PHP.

PHP:
<?PHP
    echo 'Test Message 1<br/>';
    echo "Test Message 2<br/>";
    print "Test Message 3";

/*
We can embed html code between our php codes.
The purpose of using <br> is to show the messages we have written, not side by side, but as lines.
It will go to a bottom line after each <br> tag.
*/
?>
 
Top