How to Embed PHP?
Using PHP tag (standard tag) or PHP block tells the server to execute php.
PHP shorthand tags or short open tags, this will still work but its considered bad practice.
Create a new php file using your available text editor (Notepad, Notepad++, Komodo Edit, etc.). Name it whatever you like, copy the codes below and save it.
<? ?> or <?= ?>
Open your browser (Internet Explorer, Firefox, Chrome, Opera, etc.) and type this URL http://127.0.0.1/ or http://localhost/ followed by php file name. Example: http://localhost/helloworld.php.
<html> <head> <title>PHP Embedding</title> </head> <body> <?php echo 'Hello World'; ?><br /> <?php echo 'Hello' . ' World <br />'; ?> <?php echo 18+5; ?> </body> </html>
Because we want to be a good programmer, it is important to use comments into our code so that we're able to quickly understand what the code or function commands especially very large complex programming.
We can make comments in PHP using the following:
<html> <head> <title>PHP Comments</title> </head> <body> <?php // single-line comments # single-line comments /* multi line comments multi-line comments multi-line comments multi-line comments multi-line comments multi-line comments */ ?> </body> </html>