PHP – Write First Program on PHP
As you know PHP is server side scripting language. Let me explain few lines on how PHP works with Apache server?
First of all, the user will send a request through the application layer or web browser to the server via the protocol. And the server will respond to the request by sending an HTML file back to the browser.
It means we have a .php extension of the file but the server will not display .php file, It will show you only HTML file. That is the basic working mechanism of server-side scripting language via the Apache server.
PHP has it’s own syntax to write code, syntax means rules to regulate and formulate the code in the well mannered form.
<?php // will define this is the beginning of PHP programming code.
?> // will define this is the end of PHP programming code.
First Program on PHP
<html> <head> <title> First PHP </title> </head> <body> <!-start of php code-> <?php echo 'This is My First Program on PHP'; ?> <!-end of php code-> </body> </html>
You need to run Apache server to execute your .php file. Below the output you can see the inspect element, there you can see only the HTML code, not PHP code.
PHP code is not visible to users through a web browser. It will remain visible on the server only.